【发布时间】:2016-10-10 18:57:32
【问题描述】:
我有两个图表,它们都具有相同的 x 轴,但具有不同的 y 轴缩放比例。
带有规则轴的图是带有描绘衰减趋势线的数据,而 y 半对数缩放描绘了拟合的准确性。
fig1 = plt.figure(figsize=(15,6))
ax1 = fig1.add_subplot(111)
# Plot of the decay model
ax1.plot(FreqTime1,DecayCount1, '.', color='mediumaquamarine')
# Plot of the optimized fit
ax1.plot(x1, y1M, '-k', label='Fitting Function: $f(t) = %.3f e^{%.3f\t} \
%+.3f$' % (aR1,kR1,bR1))
ax1.set_xlabel('Time (sec)')
ax1.set_ylabel('Count')
ax1.set_title('Run 1 of Cesium-137 Decay')
# Allows me to change scales
# ax1.set_yscale('log')
ax1.legend(bbox_to_anchor=(1.0, 1.0), prop={'size':15}, fancybox=True, shadow=True)
现在,我正在尝试像此链接提供的示例一样将两者紧密结合在一起 http://matplotlib.org/examples/pylab_examples/subplots_demo.html
尤其是这个
在查看示例代码时,我对如何植入 3 件事有点困惑:
1) 以不同方式缩放轴
2) 保持指数衰减图的图形大小相同,但折线图的 y 大小和 x 大小相同。
例如:
3) 保持函数的标签只出现在衰减图中。
任何帮助将不胜感激。
【问题讨论】:
标签: python matplotlib subplot