在Python交互式绘图中。我如何链接情节,以便当我放大一个图形的一个图形,它缩放所有其他的情节是在相同的数字和不同的图形,以相同的比例?它们都是按时间绘制的,即mSec。
下面是我目前正在编写的代码的一个示例。(我知道我策划了两次相同的事情,我只是在测试一些东西。)
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('data'.csv', delimiter=',', skiprows=1)
# This uses array slicing/indexing to cut the correct columns into variables.
mSec = data[:,0]
Airspeed = data[:,10]
AS_Cmd = data[:,25]
airspeed = data[:,3]
plt.rc('xtick', labelsize=15) #increase xaxis tick size
plt.rc('ytick', labelsize=15) #increase yaxis tick size
# Create a figure figsize = ()
fig1 = plt.figure(figsize= (20,20))
ax = fig1.add_subplot(211)
ax.plot(mSec, Airspeed, label='Ground speed [m/s]', color = 'r')
ax.plot(mSec, AS_Cmd, label='AS_Cmd')
plt.legend(loc='best',prop={'size':13})
ax.set_ylim([-10,40])
ax1 = fig1.add_subplot(212)
ax1.plot(mSec, Airspeed, label='Ground speed [m/s]', color = 'r')
ax1.plot(mSec, AS_Cmd, label='AS_Cmd[m/s]')
# Show the legend
plt.legend(loc='lower left',prop={'size':8})
fig1.savefig('trans2.png', dpi=(200), bbox_inches='tight') #borderless on save发布于 2016-10-06 00:27:11
sharex和sharey是你的朋友。最起码的例子:
import numpy as np
import matplotlib.pyplot as plt
fig1, (ax1, ax2) = plt.subplots(1,2,sharex=True, sharey=True)
ax1.plot(np.random.rand(10))
ax2.plot(np.random.rand(11))
fig2 = plt.figure()
ax3 = fig2.add_axes([0.1, 0.1, 0.8, 0.8], sharex=ax1, sharey=ax1)
ax3.plot(np.random.rand(12))https://stackoverflow.com/questions/39884875
复制相似问题