pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.59k stars 1.08k forks source link

Option to add individual color bar for each variable when using the Faceting #7369

Open WalidGharianiEAGLE opened 1 year ago

WalidGharianiEAGLE commented 1 year ago

Is your feature request related to a problem?

I think such feature can be very useful specially when we have different variables (example Normalized Difference Vegetation Index (NDVI) and land surface temperature (LST) which have different values) rather than a common color bar.


%matplotlib inline
import numpy as np
import pandas as pd
import xarray as xr
import matplotlib.pyplot as plt

airtemps = xr.tutorial.open_dataset("air_temperature")
air = airtemps.air - 273.15

air.attrs = airtemps.air.attrs

air.attrs["units"] = "deg C"

aot = xr.concat([air.isel(time=0)* .01, air.isel(time=100)], "time")

# assume this is NDVI
(air.isel(time=0)* .01 ).plot()

# ndvi values cant be visualized when there is a common color bar with Faceting
aot.plot(col = 'time')

Describe the solution you'd like

# manual plot
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 5))
for i in [0,1]:
    aot.isel(time=i).plot(ax = axes[i])

Rather than manual plot to adjust each color bar, it will be more efficient to integrate this option automatically when using Faceting

Describe alternatives you've considered

No response

Additional context

No response

headtr1ck commented 1 year ago

Duplicate of https://github.com/pydata/xarray/issues/7342 (but not your fault, the title is misleading).