oreomj.blogg.se

Python subplot title
Python subplot title






import numpy as npĭef set_shared_ylabel(a, ylabel, labelpad = 0.01): This way you avoid problems mentioned by KYC. Here is a solution where you set the ylabel of one of the plots and adjust the position of it so it is centered vertically. Raise Exception("Unexpected axis: x or y") Va - vertical alignment (default: "center") Ha - horizontal alignment (default: "center") Labelpad - padding from the axis (default: 5) ''' Add super ylabel or xlabel to the figure My function can also be called after the plots have been created. Wen-wei Liao's answer doesn't, because fig.add_subplot(111) will return the same Axes object if it is already created. However, if you try to call it multiple times you will get text added on top of each other (as fig.suptitle does too). Therefore there is no axes artist being created and made colorless. My answer suplabel here is similar to the fig.suptitle which uses the fig.text function. Wen-wei Liao's answer is good if you are not trying to export vector graphics or that you have set up your matplotlib backends to ignore colorless axes otherwise the hidden axes would show up in the exported graphic.

python subplot title

Plt.savefig('common_labels_text.png', dpi=300) Plt.savefig('common_labels.png', dpi=300)Īnother way is using fig.text() to set the locations of the common labels directly. # Turn off axis lines and ticks of the big subplotĪx.tick_params(labelcolor='w', top=False, bottom=False, left=False, right=False)

python subplot title

Y2 = Īx = fig.add_subplot(111) # The big subplot

python subplot title

You can create a big subplot that covers the two subplots and then set the common labels.








Python subplot title