开发者

How to put minorticks on both the sub plots?

开发者 https://www.devze.com 2023-02-08 18:18 出处:网络
I am having two sub plots in the figure.How to add the minor ticks on both x and y axis of both the sub plots?

I am having two sub plots in the figure. How to add the minor ticks on both x and y axis of both the sub plots?

Also, How can I put the y-label for the right sub plot on the right side of the y axis? Can you please answer the above questions? The piece of code is as follows:

# Open the figure to plot the Gain variations for this frequencies
fig = plt.figure()
ax = plt.subplot(121) # To show the ascending order
plt.xlabel ('RF Input Power (dBm)', fontsize = 'smaller')
plt.ylabel ('Gain (dB)', fontsize = 'smaller')
tx = plt.title('Gain Vs Ascending RFInput for ' + str(measuredFrequencyUnderTest) + 'MHz', fontsize = 'smaller')
plt.minorticks_on()

ay = plt.subplot(122, xlim = [rfInputMax, rfInputMin], ylim = [-18.0, 30.0]) # To show the descending order
plt.xlabel ('RF Input Power (dBm)', fontsize = 'smaller')
plt.ylabel ('Gain (dB)', fontsize = 'smaller', horizontalalignment = 'left') 
ty = plt.title('Gain Vs Descending RF Input for '+ str(measuredFrequencyUnderTest)+ 'MHz', font开发者_如何学JAVAsize = 'smaller')

This code is inserting the minorticks only on the first sub plot. Even if I have the command "plt.minorticks_on" for both sub-plots, they are not appearing on both the sub-plots.

I need your advice on that.

Thanking you Gopi


Just call minorticks_on() on the axes and not on the pyplot object:

ax = plt.subplot(121)
#....
ax.minorticks_on()

ay = plt.subplot(122, ...)
#...
ay.minorticks_on()
0

精彩评论

暂无评论...
验证码 换一张
取 消