FIX: unit-convert pcolorargs before interpolating by jklymak · Pull Request #18549 · matplotlib/matplotlib · GitHub
Skip to content

FIX: unit-convert pcolorargs before interpolating - #18549

Merged
tacaswell merged 2 commits into
matplotlib:masterfrom
jklymak:fix-pcolorarg-convert-before-interp
Sep 23, 2020
Merged

tacaswell merged 2 commits into
matplotlib:masterfrom
jklymak:fix-pcolorarg-convert-before-interp

Conversation

@jklymak

@jklymak jklymak commented Sep 23, 2020

Copy link
Copy Markdown
Member

PR Summary

Closes #18547

For pcolor(mesh) the new "nearest" interpolation was being done before unit conversion, so datetime (for instance) did not work. This moves unit conversion inside _pcolorargs.

from datetime import datetime

from matplotlib import pyplot as plt

x_coords = [datetime.fromtimestamp(x * 3600) for x in range(24)]
y_coords = [*range(0, 10)]
plt.pcolormesh(x_coords,
               y_coords, [[*range(24)] for _ in range(10)],
               shading="nearest")

plt.show()

failed before, and works now...

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@jklymak
jklymak force-pushed the fix-pcolorarg-convert-before-interp branch from d471a21 to 9a1af30 Compare September 23, 2020 13:57
@jklymak jklymak added this to the v3.3.3 milestone Sep 23, 2020
@jklymak
jklymak force-pushed the fix-pcolorarg-convert-before-interp branch from 7c0711c to 9474ee6 Compare September 23, 2020 14:39
@jklymak
jklymak force-pushed the fix-pcolorarg-convert-before-interp branch from 9474ee6 to 75097a2 Compare September 23, 2020 14:44
@jklymak
jklymak marked this pull request as ready for review September 23, 2020 15:11
@tacaswell
tacaswell merged commit a010c54 into matplotlib:master Sep 23, 2020
@lumberbot-app

lumberbot-app Bot commented Sep 23, 2020

Copy link
Copy Markdown

@jklymak

jklymak commented Sep 23, 2020

Copy link
Copy Markdown
Member Author

@jklymak
jklymak deleted the fix-pcolorarg-convert-before-interp branch September 23, 2020 18:19
jklymak pushed a commit to jklymak/matplotlib that referenced this pull request Sep 23, 2020
…t-before-interp

FIX: unit-convert pcolorargs before interpolating
@jklymak jklymak mentioned this pull request Sep 23, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pcolormesh x-axis with datetime broken for nearest shading

4 participants