Conversation
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
| values1 = np.random.randint(1, 10, 30) | ||
| values2 = np.random.randint(1, 10, 30) | ||
| values3 = np.random.randint(1, 10, 30) |
There was a problem hiding this comment.
If you want to use randomness, you'll need to set a seed (we use 19680801 for tests).
| hist2d1 = ax1.hist2d( | ||
| x_values, | ||
| values1, | ||
| bins=10, | ||
| cmap='Blues' | ||
| ) |
| hist2d2 = ax2.hist2d( | ||
| x_values, | ||
| values2, | ||
| bins=10, | ||
| cmap='Greens' | ||
| ) | ||
| ax2.set_title('Axes.hist2d - Data 2') | ||
|
|
||
| hist2d3 = ax3.hist2d( | ||
| x_values, | ||
| values3, | ||
| bins=10, | ||
| cmap='Reds' | ||
| ) | ||
| ax3.set_title('Axes.hist2d - Data 3') |
There was a problem hiding this comment.
I don't see what the difference is between the first plot and these two?
There was a problem hiding this comment.
To possibly clarify a bit: it would make more sense to use dates for the y-values as well. So one idea is to keep one of the subplots, swap x and y values for the next (dates on y-axis) and let the third have dates for both x and y-values.
Co-authored-by: Kyle Sunden <[email protected]>
| values2 = np.random.randint(1, 10, 30) | ||
| values3 = np.random.randint(1, 10, 30) | ||
|
|
||
| x_values = mpl.dates.date2num([start_date + i * time_delta for i in range(30)]) |
There was a problem hiding this comment.
date2num means you are passing numbers into hist2d. We want to test actual dates.
| x_values = mpl.dates.date2num([start_date + i * time_delta for i in range(30)]) | ||
|
|
||
| # Using Axes.hist2d | ||
| fig, (ax1, ax2, ax3) = plt.subplots(1, 3, constrained_layout=True) |
There was a problem hiding this comment.
| fig, (ax1, ax2, ax3) = plt.subplots(1, 3, constrained_layout=True) | |
| fig, (ax1, ax2, ax3) = plt.subplots(1, 3, layout='constrained') |
PR summary
I have added a test for Axes.hist2d in lib/matplotlib/tests/test_datetime.py that tests with randomly created data if the data correctly plots. It is similar to the Axes.hist method of testing, as it uses similar generated data and methods.
This addresses the Axes.hist2d task from #26864.
Below is a picture of the generated plots.

PR checklist