pydata / pydata/xarray

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

Open
#7,369 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement topic-plotting
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the faceted plotting entry point shown by aot.plot(col='time') and compare its behavior with the manual matplotlib subplots example. Determine how separate colorbars should be represented and positioned for facets with different value ranges, then add coverage using the differing-scale example and verify each facet has an appropriate colorbar.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.