试图将地块彼此相邻

时间:2016-07-31 19:37:13

标签: python matplotlib

我试图将两个地块放在一起,但我不知道它是怎么做的。

这是第一个情节:

x_new = np.linspace(dsa[0], dsa[-1], num=len(dsa)*10)
coefs = poly.polyfit(dsa, Wechsel, 1)
ffit = poly.polyval(x_new, coefs)
plt.grid(True)
plt.xlabel("Druck p in mbar")
plt.ylabel("Minimawechsel N")
plt.plot(x_new, ffit, color="red", linestyle="solid", linewidth=1)
plt.plot(dsa, Wechsel, 'ro', label="Sauerstoff")
plt.legend(loc=1)

这是第二个:

x_new1 = np.linspace(dar[0], dar[-1], num=len(dar)*10)
coefs1 = poly.polyfit(dar, Wechsel, 1)
ffit1 = poly.polyval(x_new1, coefs1)
plt.grid(True)
plt.xlabel("Druck p in mbar")
plt.ylabel("Minimawechsel N")
plt.plot(x_new1, ffit1, color="blue", linestyle="solid", linewidth=1)
plt.plot(dar, Wechsel, 'ro', color='blue', label="Argon")
plt.legend(loc=1)

1 个答案:

答案 0 :(得分:0)

您可以使用plt.subplots

f, (ax1, ax2) = plt.subplots(1, 2)

x_new = np.linspace(dsa[0], dsa[-1], num=len(dsa)*10)   
coefs = poly.polyfit(dsa, Wechsel, 1)
ffit = poly.polyval(x_new, coefs)
ax1.grid(True) 
ax1.set_xlabel("Druck p in mbar")                   
ax1.set_ylabel("Minimawechsel N")
ax1.plot(x_new, ffit, color="red", linestyle="solid", linewidth=1)
ax1.plot(dsa,Wechsel,'ro', label="Sauerstoff" )
ax1.legend(loc=1)

与ax2类似:

x_new1 = np.linspace(dar[0], dar[-1], num=len(dar)*10)   
coefs1 = poly.polyfit(dar, Wechsel, 1)
ffit1 = poly.polyval(x_new1, coefs1)
ax2.grid(True)                              
ax2.set_xlabel("Druck p in mbar")                   
ax2.set_ylabel("Minimawechsel N")
ax2.plot(x_new1, ffit1, color="blue", linestyle="solid", linewidth=1)
ax2.plot(dar,Wechsel, 'ro',color='blue', label="Argon")
ax2.legend(loc=1)