Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在两个子图上放置minorticks?_Python_Matplotlib - Fatal编程技术网

Python 如何在两个子图上放置minorticks?

Python 如何在两个子图上放置minorticks?,python,matplotlib,Python,Matplotlib,图中有两个子图。如何在两个子图的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)', fonts

图中有两个子图。如何在两个子图的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')
此代码仅在第一个子图上插入MINORTICK。即使我有两个子图的命令“plt.minorticks_on”,它们也不会出现在两个子图上

我需要你的建议

谢谢你
Gopi

只需在轴上而不是在
pyplot
对象上调用
minorticks\u on()

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

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

什么图形库?到目前为止你试过什么?请出示一些代码。否则没有人会知道你在说什么。谢谢Tim,我在第一个问题中添加了一段代码。仍然不知道你在使用什么图形库。@Andrea:编辑过的标记,可能会吸引一些能回答的人。另外,使用字符串格式,而不是使用“somestring”+str(var)+“otherstring”。(>'somestring%d其他字符串“%var”)。感谢Andrea的回答。但对于ax子地块,它正在发挥作用。但对于ay,您的方法看不到微小的滴答声。我可能还是做错了什么。你能帮帮我吗?GopiHi,我尝试了我发布的代码,效果很好。。你能用一个不起作用的最少的例子来更新这个问题吗?请删除所有无关变量,只留下一个包含两个子地块的绘图。(在此过程中,您可能会发现错误所在:))