-
Notifications
You must be signed in to change notification settings - Fork 0
/
secondXorYAxis
41 lines (32 loc) · 1.17 KB
/
secondXorYAxis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
##example of second Y axis
fig, ax1 = plt.subplots()
color = 'tab:red'
ax1.set_xlabel('time [min]')
ax1.set_ylabel('thvm [K]', color=color)
ax1.plot(thv[40:60,30], color=color)
ax1.tick_params(axis='y', labelcolor=color)
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
color = 'tab:blue'
ax2.set_ylabel('cloud_frac', color=color) # we already handled the x-label with ax1
ax2.plot(cf[40:60,30], color=color)
ax2.tick_params(axis='y', labelcolor=color)
fig.tight_layout() # otherwise the right y-label is slightly clipped
plt.show()
### example of 2 X axes
col=7
fig=plt.figure()
ax1=fig.add_subplot(1,1,1)
color = 'tab:red'
#ax1.set_xlabel('w_median [m/s]',color=color)
#ax1.set_ylabel('Height [m]')
ax1.plot(Z[:,0,col],rng[:,0,col], color=color,label='1')
#ax1.plot(w[time,0:top],dlh[0:top], color=color,linestyle='dashed',label='2')
#ax1.tick_params(axis='x', labelcolor=color)
#ax1.legend()
ax2=ax1.twiny()
color = 'tab:blue'
#ax2.set_xlabel('w_variance [m2 s-2]', color=color)
ax2.plot(rr[250,:,0,0,col],alt, color=color)
#ax2.plot(wvar_nan[time,0:top],dlh[0:top], color=color,linestyle='dashed')
#ax2.tick_params(axis='x', labelcolor=color)
plt.show()