我试着画出3个子图,它们之间没有任何空白。默认的y轴勾选标签使用显示在y轴右上角的比例(在下面的示例中为1e-8),除了下面两个与上面的图重叠的绘图之外,其他都可以。有人知道怎么解决这个问题吗?下面是一个小例子。在
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from matplotlib.ticker import MaxNLocator
x = np.arange(0,200)
y = np.random.rand(200) * 10e-8
fig = plt.figure(figsize=(10,15))
gs1 = gridspec.GridSpec(3, 3)
gs1.update(left=0.1, right=0.9, bottom=0.5, hspace=0.0)
ax0a = plt.subplot(gs1[0, :])
ax0b = plt.subplot(gs1[1, :])
ax0c = plt.subplot(gs1[2, :])
ax0a.set_xticklabels([])
ax0b.set_xticklabels([])
ax0a.plot(x,y)
nbins = len(ax0a.get_xticklabels())
ax0a.yaxis.set_major_locator(MaxNLocator(nbins=nbins, prune='upper'))
ax0b.plot(x,y)
ax0b.yaxis.set_major_locator(MaxNLocator(nbins=nbins, prune='upper'))
ax0c.plot(x,y)
ax0c.yaxis.set_major_locator(MaxNLocator(nbins=nbins, prune='upper'))
所以一个解决方案是使用mtick
^{pr2}$但我更希望能将刻度向左移动,这样它就在轴之外,如果可能的话。在
我有两个选择你可能想看看。在
首先,按如下方式设置轴位置和大小:
第二个选项是手动调整偏移文本的位置和字体大小:
^{pr2}$好吧,这可能是一个丑陋的解决方案,但你可以只是简单的高档次 下面的数据显示了幂的范围,即
ax0b.plot(x, y*1e8)
。 这至少对你的例子有效。在相关问题 更多 >
编程相关推荐