我正在尝试制作一个类似于以下内容的颜色幅度图:
我有三个数组,它们包含完全相同数量的值。你知道吗
x1
=B-V(-.5到2)
x2
=温度。(30000到3000)并且需要是对数刻度
y1
=震级(根据其他震级而变化)
x1
、x2
和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()
如果我理解正确的话,你应该只需要在图的右边缘选取一个点,在那里轴应该对齐,matplotlib将从那里获取它。你知道吗
要确定点,计算出哪个轴(线性或对数)沿x轴需要更多的“空间”,将其限制设置为其最大值,然后将其转换为另一个轴的坐标空间以将其用作限制。你知道吗
相关问题 更多 >
编程相关推荐