2013-05-13 47 views
2

我试图做类似颜色星图:如何在不同的尺度上操纵多个x轴以相互对应?

B-V Diagram

我有一个包含确切相同数量的值的三个阵列。

x1 = B-V(-.5至2)

x2 =温度。 (30000〜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() 

回答

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轴的“空间”,设置它的极限作为其最大值,然后将其转换成其他的坐标空间轴将其用作其极限。