test_tripcolor (Issue #26864) plots with datetime on x-axis only , y-axis only, and both x- and y-axis#27491
test_tripcolor (Issue #26864) plots with datetime on x-axis only , y-axis only, and both x- and y-axis#27491bikegeek wants to merge 1 commit intomatplotlib:mainfrom
Conversation
…nd both x- and y-axis
jklymak
left a comment
There was a problem hiding this comment.
Can you do something like x_random_dates = np.datetime64('2020-01-01') + x.as_type('timedelata64[D]')? That way the underlying surface will not be randomized.
| ax1.set(xlim=(min(x), max(x)), ylim=(min(y_rand_dates), max(y_rand_dates))) | ||
| ax2.set(xlim=(min(x_rand_dates), max(x_rand_dates)), ylim=(min(y_rand_dates), | ||
| max(y_rand_dates))) | ||
| fig.tight_layout() |
There was a problem hiding this comment.
| fig.tight_layout() |
| mpl.rcParams["date.converter"] = 'concise' | ||
| plt.style.use('_mpl-gallery-nogrid') | ||
|
|
||
| fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4)) |
There was a problem hiding this comment.
| fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4)) | |
| fig, (ax, ax1, ax2) = plt.subplots(3, 1, figsize=(6, 4), layout='constrained') |
| fig, ax = plt.subplots() | ||
| ax.tripcolor(...) | ||
| mpl.rcParams["date.converter"] = 'concise' | ||
| plt.style.use('_mpl-gallery-nogrid') |
There was a problem hiding this comment.
| plt.style.use('_mpl-gallery-nogrid') |
The gallery-style is not used for tests (and is already set by @mpl.style.context("default")).
|
I think that this is actually relatively recent that it works (thanks to probably #24522) but it does seem to work now, which is good. (I tested on a machine I hadn't pulled for a while on, and it didn't work, but after pulling it worked) The second plot ( |
|
Thats why I'd prefer the background data was retained, rather than be scrambled. |
|
Further testing has shown that The axis units are not updated (and in fact I'm pretty sure if we used a different scale (other than As such I'm inclined to not merge this for the time being (until the underlying problems are fixed) Though perhaps remove the |
PR summary
Added code to test the tripcolor plotting with np.datetimes, based on the tripcolor(x,y,z) example in the Matplotlib user documentation. This is one of the numerous sub-tasks identified for testing various Axes.plottype ( where plottype= hist, scatter, violin, etc.) described in issue #26864
Generated plots look like the following:
PR checklist