如何在两个子图上添加小记号?
我在图中有两个子图。如何在两个子图的 x 轴和 y 轴上添加小刻度?
另外,如何将右侧子图的 y 标签放在 y 轴的右侧? 您能回答一下以上问题吗? 该代码如下:
# 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', fontsize = 'smaller')
该代码仅在第一个子图上插入小记号。即使我对两个子图都有命令“plt.minorticks_on”,它们也不会出现在两个子图上。
我需要你的建议。
谢谢你 戈皮
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', fontsize = '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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在坐标轴上调用
minorticks_on()
即可,而不是在pyplot
对象上调用:Just call
minorticks_on()
on the axes and not on thepyplot
object: