pydata / pydata/xarray

Colormap/palette for lineplot's hue

Open
#10,674 1 comment 2 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?

hue argument works for xr.plot.line() but there is no way to control in the function call the colormap.
Right now, one has to manually create an axis, modify its cycler and then pass the ax to the plot function.
Hence one cannot create the axis with the plot function there one cannot use the "size" argument of the plot function for example, and one has to manually pick the number of colorlevels needed :

fig,ax = plt.subplots(figsize=(8,5))

ds2plot = ...
ax.set_prop_cycle(cycler(color=plt.get_cmap('magma_r')(np.linspace(0.15, 1, len(ds2plot.time)))))

ds2plot.plot(y="altitude", hue = "time", ax =ax)
Describe the solution you'd like

ds2plot.plot(y="altitude", hue = "time", cmap="magma_r")
And why not colormap arguments (i.e min, max for the color coding like in my previous functioning example).

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 at the xr.plot.line() entry point and inspect how hue is handled for line plots. Check the existing plot-call arguments and determine how cmap and optional color-range limits should fit while preserving size and ax behavior. Done means the requested call works with a colormap; add focused coverage for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.