Skip to content

Use a default value for constant dimensions #7281

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

Merged
merged 2 commits into from
Nov 20, 2022

Conversation

Illviljan
Copy link
Contributor

@Illviljan Illviljan commented Nov 11, 2022

  • default markersize values of widths are 18 to 72.
  • plt.scatter default markersize is 36.
  • plt.plot default linewidth is 6.

With main we get 18 for constant arrays, but 36 if markersize was undefined. This seems a bit inconsistent to me.
This PR adds a default value instead for constant arrays

Follow up to #7272.

@Illviljan
Copy link
Contributor Author

Illviljan commented Nov 11, 2022

Markersize before PR:
image

Markersize after PR:
image

import numpy as np
import matplotlib.pyplot as plt

import xarray as xr

temp = xr.DataArray(np.random.randn(10, 10, 2), coords=[np.arange(10), np.arange(10), [2021, 2022]], dims=["lon", "lat", "year"])
prec = xr.DataArray(np.random.randn(10, 10, 2), coords=[np.arange(10), np.arange(10), [2021, 2022]], dims=["lon", "lat", "year"])
one = xr.DataArray(np.random.randn(10, 10, 2), coords=[np.arange(10), np.arange(10), [2021, 2022]], dims=["lon", "lat", "year"])
blue = xr.DataArray(np.random.randn(10, 10, 2), coords=[np.arange(10), np.arange(10), [2021, 2022]], dims=["lon", "lat", "year"])
ds = xr.Dataset({"temperature": temp, "precipitation": prec, 1: one, "blue": blue})

# Stack the non interesting dims:
# fig, ax = plt.subplots()
# ds.stack(stacked_dim=[...]).plot.scatter(x="temperature", y="precipitation")

fig, ax = plt.subplots()
ds.plot.scatter(x="temperature", y="precipitation", markersize=1)

@Illviljan Illviljan marked this pull request as ready for review November 11, 2022 19:19
@Illviljan Illviljan changed the title Add a default value for constant dimensions Use a default value for constant dimensions Nov 11, 2022
@@ -51,8 +51,8 @@
ROBUST_PERCENTILE = 2.0

# copied from seaborn
_MARKERSIZE_RANGE = (18.0, 72.0)
_LINEWIDTH_RANGE = (1.5, 6.0)
_MARKERSIZE_RANGE = (18.0, 36.0, 72.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really a range anymore, but since it is internal only I don't care much.

@headtr1ck headtr1ck added the plan to merge Final call for comments label Nov 16, 2022
@Illviljan Illviljan merged commit 9dd3c1b into pydata:main Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments topic-plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants