我试图修复python如何绘制我的数据.
说
x = [0,5,9,10,15]
Run Code Online (Sandbox Code Playgroud)
和
y = [0,1,2,3,4]
Run Code Online (Sandbox Code Playgroud)
然后我会这样做:
matplotlib.pyplot.plot(x,y)
matplotlib.pyplot.show()
Run Code Online (Sandbox Code Playgroud)
并且x轴'刻度以5为间隔绘制.有没有办法让它显示间隔为1?
我试图在matplotlib子图环境中将格式设置为两个十进制数.不幸的是,我不知道如何解决这个任务.
为了防止在y轴上使用科学记数法,我ScalarFormatter(useOffset=False)
可以在下面的代码片段中看到.我认为我的任务应该通过将更多的选项/参数传递给使用的格式化程序来解决.但是,我在matplotlib的文档中找不到任何提示.
如何设置两位小数或无(两种情况都需要)?遗憾的是,我无法提供样本数据.
- SNIPPET -
f, axarr = plt.subplots(3, sharex=True)
data = conv_air
x = range(0, len(data))
axarr[0].scatter(x, data)
axarr[0].set_ylabel('$T_\mathrm{air,2,2}$', size=FONT_SIZE)
axarr[0].yaxis.set_major_locator(MaxNLocator(5))
axarr[0].yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
axarr[0].tick_params(direction='out', labelsize=FONT_SIZE)
axarr[0].grid(which='major', alpha=0.5)
axarr[0].grid(which='minor', alpha=0.2)
data = conv_dryer
x = range(0, len(data))
axarr[1].scatter(x, data)
axarr[1].set_ylabel('$T_\mathrm{dryer,2,2}$', size=FONT_SIZE)
axarr[1].yaxis.set_major_locator(MaxNLocator(5))
axarr[1].yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
axarr[1].tick_params(direction='out', labelsize=FONT_SIZE)
axarr[1].grid(which='major', alpha=0.5)
axarr[1].grid(which='minor', alpha=0.2)
data = conv_lambda
x = range(0, len(data))
axarr[2].scatter(x, data)
axarr[2].set_xlabel('Iterationsschritte', size=FONT_SIZE)
axarr[2].xaxis.set_major_locator(MaxNLocator(integer=True))
axarr[2].set_ylabel('$\lambda$', size=FONT_SIZE)
axarr[2].yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
axarr[2].yaxis.set_major_locator(MaxNLocator(5))
axarr[2].tick_params(direction='out', labelsize=FONT_SIZE)
axarr[2].grid(which='major', alpha=0.5)
axarr[2].grid(which='minor', alpha=0.2)
Run Code Online (Sandbox Code Playgroud)