-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use plt.rc_context for default styles #7318
Use plt.rc_context for default styles #7318
Conversation
for more information, see https://pre-commit.ci
Seaborn did something similar as the original but had a little check if the marker was filled or not: |
…m/Illviljan/xarray into use_rc_context_for_default_styles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not check what seaborn is doing exactly, but it seems like a reasonable approach.
Co-authored-by: Mathias Hauser <[email protected]>
plt = import_matplotlib_pyplot() | ||
if Version(plt.matplotlib.__version__) < Version("3.5.0"): | ||
ax.view_init(azim=30, elev=30) | ||
with plt.rc_context(_styles): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this override any user style settings in .matplotlibrc
so if they chose a default of black
we'd be overwriting that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the innermost context takes priority. edgecolor="k"
can be used though.
We have the same problem with color maps:
ds = xr.tutorial.scatter_example_dataset(seed=42)
fig, axs = plt.subplots(1, 2)
with plt.rc_context(
{
"scatter.edgecolors": "k",
"image.cmap": "Greys",
}
):
# Normal scatter:
axs[0].scatter(ds.A.values.ravel(), ds.B.values.ravel(), c=3 * ds.B.values)
# xarray scatter:
ds.plot.scatter(x="A", y="B", ax=axs[1])
This has stalled for long enough. I'll merge this at the end of next week unless someone disagrees, at least it is an improvement to the bugged main. |
* upstream/main: (291 commits) Update error message when saving multiindex (pydata#7475) DOC: cross ref the groupby tutorial (pydata#7555) [pre-commit.ci] pre-commit autoupdate (pydata#7543) supress namespace_package deprecation warning (doctests) (pydata#7548) [skip-ci] Add PDF of Xarray logo (pydata#7530) Support complex arrays in xr.corr (pydata#7392) clarification for thresh arg of dataset.dropna() (pydata#7481) [pre-commit.ci] pre-commit autoupdate (pydata#7524) Require to explicitly defining optional dimensions such as hue and markersize (pydata#7277) Use plt.rc_context for default styles (pydata#7318) Update HOW_TO_RELEASE.md (pydata#7512) Update whats-new for dev (pydata#7511) Fix whats-new for 2023.02.0 (pydata#7506) Update apply_ufunc output_sizes error message (pydata#7509) Zarr: drop "source" and "original_shape" from encoding (pydata#7500) [pre-commit.ci] pre-commit autoupdate (pydata#7507) Whats-new for 2023.03.0 Add `inclusive` argument to `cftime_range` and `date_range` and deprecate `closed` argument (pydata#7373) Make text match code example (pydata#7499) Remove Dask single-threaded setting in tests (pydata#7489) ...
whats-new.rst