2

次のような色の大きさ図を作成しようとしています。

BVダイアグラム

まったく同じ数の値を含む 3 つの配列があります。

x1= BV (-.5 ~ 2)

x2= 温度。(30,000 から 3000) であり、対数スケールである必要があります

y1= マグニチュード (他によって異なります)

x1x2およびy1配列はすべてリンクされており、それらを一緒に散布図にプロットしたいと思います。

私のコード:

#PLOTS
x1 = bv_array       #B-V
x2 = t_array        #Temperature
y1 = Vavg_array     #Magnitude
fig = plt.figure()

ax1 = fig.add_subplot(111)
#ax1.xlim(-.5,2)
ax1.plot(x1, y1,'b--')
ax2 = ax1.twiny()
ax2.plot(x2, y1, 'go')
ax2.set_xlabel('Temperature')
ax2.invert_xaxis()

#ax2.xscale('log')
#plt.xscale('log')
#plt.scatter(x,y)

#plt.scatter(bv_array, Vavg_array, s = 1)
plt.gca().invert_yaxis()

plt.show()
4

1 に答える 1

1

私があなたを正しく理解していれば、グラフの右端で軸を揃える必要がある単一の点を選択できるはずで、matplotlib はそこからそれを取得します。

ax1 = fig.add_subplot(111)

ax1.xlim(-.5,2) # Set it in axis 1 coords

ax1.plot(x1, y1,'b--')
ax2 = ax1.twiny()
ax2.plot(x2, y1, 'go')
ax2.set_xlabel('Temperature')
ax2.invert_xaxis()

ax2.xlim(-2, 3) # Set it in axis 2 coords

ポイントを決定するには、どの軸 (線形または対数) が x 軸に沿ってより多くの「スペース」を必要とするかを判断し、その限界を最大として設定し、それを他の軸の座標空間に変換して限界として使用します。 .

于 2013-05-13T21:02:00.737 に答える