Plot common colorbar¶
In [1]:
Copied!
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
import xarray as xr
imshow¶
In [2]:
Copied!
x = np.arange(-5,5)
y = np.arange(-6,4)
fig, axs = plt.subplots(nrows=2, ncols=2)
for ax in axs.flat:
im = ax.pcolormesh(x,y, np.random.random((10,10)), vmin=0, vmax=1)
fig.subplots_adjust(right=0.8)
# [x0,y0,width,height]
cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
fig.colorbar(im, cax=cbar_ax)
x = np.arange(-5,5)
y = np.arange(-6,4)
fig, axs = plt.subplots(nrows=2, ncols=2)
for ax in axs.flat:
im = ax.pcolormesh(x,y, np.random.random((10,10)), vmin=0, vmax=1)
fig.subplots_adjust(right=0.8)
# [x0,y0,width,height]
cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
fig.colorbar(im, cax=cbar_ax)
Out[2]:
<matplotlib.colorbar.Colorbar at 0x76bff32f5fd0>
xarray data_vars¶
Not working , needs to read ldasout_wrf
In [3]:
Copied!
fg= xr.concat([
ldasout_wrf['ACCPRCP'].isel(time=-1),
ldasout_sup['ACCPRCP'].isel(time=-1)],
dim='new_dim').plot(x='ix', y='iy', col='new_dim', cmap='gist_ncar')
titles = ['wrf', 'sup']
for i,ax in enumerate(fg.axs.flatten()):
ax.axis(zoom_land)
ax.set_title(titles[i])
fg= xr.concat([
ldasout_wrf['ACCPRCP'].isel(time=-1),
ldasout_sup['ACCPRCP'].isel(time=-1)],
dim='new_dim').plot(x='ix', y='iy', col='new_dim', cmap='gist_ncar')
titles = ['wrf', 'sup']
for i,ax in enumerate(fg.axs.flatten()):
ax.axis(zoom_land)
ax.set_title(titles[i])
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[3], line 2 1 fg= xr.concat([ ----> 2 ldasout_wrf['ACCPRCP'].isel(time=-1), 3 ldasout_sup['ACCPRCP'].isel(time=-1)], 4 dim='new_dim').plot(x='ix', y='iy', col='new_dim', cmap='gist_ncar') 6 titles = ['wrf', 'sup'] 7 for i,ax in enumerate(fg.axs.flatten()): NameError: name 'ldasout_wrf' is not defined
In [ ]:
Copied!