我现在正在制作许多情节,有些看起来很棒,而其他需要一些调整.从下面我怎样才能让难以看到的情节线更容易看到而无需手动绘制它们?我一次绘制50-100个这些,然后将它们添加到pdf报告中.我想在线下添加空格,例如将ylim min limit设置为-0.1,但是会自动执行.
这个很难看出情节线:
这个很容易看到情节线:
这是我的绘图代码:
def plot(chan_data):
'''Uses matplotlib to plot a channel
'''
f, ax = plt.subplots(1, figsize=(8, 2.5))
x = dffinal['time'].keys()
ax.plot(x, dffinal[chan_data].values, linewidth=0.4, color='blue')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%m/%d/%Y - %H:%M'))
ax.xaxis.set_major_locator(mdates.AutoDateLocator(interval_multiples=True))
lgd1 = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
f.autofmt_xdate()
ax.set_ylabel(dffinal[chan_data].name)
ax.grid('on')
#I've tried these with no luck
#ax.autoscale(enable=True, axis='y', tight=False)
#ax.set_ymargin(0.5)
#ax.set_autoscaley_on(True)
fname = ".\\plots\\" + chan_data + ".png"
print "Creating: " + fname
plt.savefig(fname, dpi=100, bbox_extra_artist=(lgd1,), bbox_inches='tight')
plt.close()
return fname
Run Code Online (Sandbox Code Playgroud) 如何在我用matplotlib绘制的点周围创建空间?
例如,在该图中,左下角由轴截止,但我想在点和轴之间留出更多的空间.
import matplotlib.pyplot as plt
x = [2**i for i in xrange(4,14)]
y = [i**2 for i in x]
plt.loglog(x,y,'ro',basex=2,basey=2)
plt.xlim([0, 2**14]) # <--- this line does nothing
plt.show()
Run Code Online (Sandbox Code Playgroud)
在交互模式下,该xlim
行返回(16.0, 16384)
旧值而不是我试图设置的新值.