faceted plot uses wrong vmin and vmax #7605
Answered
by
keewis
WalidGharianiEAGLE
asked this question in
General
-
I was curious to extract the vmin and vmax used with faceted plot, and i found out that it doesn't use the right values. import xarray as xr
import numpy as np
airtemps = xr.tutorial.open_dataset("air_temperature")
air = airtemps.air - 273.15
t = air.isel(time=slice(0, 365 * 4, 250))
t.coords
t.plot(x="lon", y="lat", col="time", col_wrap=3)
## lets check the min and max of the air DataArray
min_air, max_air = np.nanmin(t.values) , np.nanmax(t.values)
print(min_air, max_air)
## >> -46.550003 36.950012
## the max is max_air = 36.950012 while in the facet plot, the vmax is more than 40. why is that ? |
Beta Was this translation helpful? Give feedback.
Answered by
keewis
Mar 16, 2023
Replies: 1 comment 1 reply
-
That's because the function detects a diverging dataset and thus centers around vmax = max(abs(min), abs(max))
vmin = -vmax if that's not what you want, you can disable this using t.plot(x="lon", y="lat", col="time", col_wrap=3, center=False) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
WalidGharianiEAGLE
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's because the function detects a diverging dataset and thus centers around
0
:if that's not what you want, you can disable this using
center=False
: