简体   繁体   English

我可以将x轴旋转45度吗? 试图使象形图

[英]Can I rotate the x axis by 45 degrees? Trying to make tephigram

I need to have the y axis as it but rotate my x axis by 45 degrees. 我需要使用y轴,但将x轴旋转45度。 cannot seem to find any help about this online. 似乎无法在网上找到任何帮助。 cheers in advance for any help. 提前为您提供帮助。

code is as follows 代码如下

t = nwp.get('T','1000 hPa')

lon,lat = nwp.grid()
a,b = common.gridij3(174.,-41.,lon,lat)

pressure=[1000,950,925,850,700,600,500,400,300,250,150,100]

tt=[]
td=[]
tw=[]
for level in pressure:
    tt.append(nwp.get('T','%i hPa' %level)[a,b]) # % means add hPa to value taken from level list
    td.append(nwp.get('TD','%i hPa' %level)[a,b])
    tw.append(nwp.get('TW','%i hPa' %level)[a,b])

print '---Temperatures---'
for t in tt:
    print t
print '---Dew points---'
for t in td:
    print t
print '---Wet bulb temperatures---'
for t in tw:
    print t


#invert pressure axis
plt.gca().invert_yaxis()
#need to know how to rotate x axis by 45

plt.xlabel('Temperature K')
plt.ylabel('Pressure hPa')

plt.yscale('log')

plt.plot(tt,pressure,'r',label='Temp')
plt.plot(td,pressure,label='Dew Point')
plt.plot(tw,pressure,'g',label='Wet Bulb Temperature')
plt.legend()

plt.show()

You didn't say which direction, do you have the degrees for your variable? 您没有说哪个方向,您有变量的度数吗?

I envision something like a basic if/else: 我设想类似基本的if / else:

If your new axis goes past 360, take 360 - your axis then rotate - difference and add that to 0. 如果您的新轴超过360,则取360-您的轴然后旋转-差并将其添加到0。

// pseudocode //伪代码

if x-axis + rotate < 360 x-axis = x-axis + 45 else x-axis = 0 + (45 - (360 - x-axis)) 如果x轴+旋转<360 x轴= x轴+ 45否则x轴= 0 +(45-(360-x轴))

I found half a dozen useful pages by Googling "matplotlib skew-T"; 通过谷歌搜索“ matplotlib skew-T”,我发现了六个有用的页面;

the general approach, exemplified by Plotting straight line on semilog plot with matplotlib seems to be to calculate an appropriate x-offset for each data point, rather than rotating the axis. 一般的方法,例如用matplotlib在半对数图上绘制直线,似乎是为每个数据点计算适当的x偏移,而不是旋转轴。

You might also find https://github.com/tchubb/SkewT useful. 您可能还会发现https://github.com/tchubb/SkewT有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM