-
Notifications
You must be signed in to change notification settings - Fork 47
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
Colormap not preserved in scatter plot when generating baseline plot. #84
Comments
Any chance you can boil that down to a basic matplotlib plot that reproduces the failure? There's a lot of stuff that uses |
I faced a similar issue today as well when plotting with Those black lines are essentially all the edges being coloured in. Seems like |
I believe the differences are due to pytest-mpl using the I hope to make this the default in pytest-mpl |
@ConorMacBride Hi, thanks for the hint. Yes, setting For what it's worth, I made a (somewhat) minimal example, I'm assuming it's tangentially related to what the OP was experiencing. @pytest.mark.mpl_image_compare(
style="default", # v.s. "classic"
)
def test_myfoo():
import matplotlib.pyplot as plt
import numpy as np
ys=np.array([[1.23710908e-03, 4.20836477e-02, 2.09052698e-01, 2.67737557e-01,
1.31218302e-01],
[1.43456874e-01, 2.25156978e-01, 3.83926106e-01, 4.14150010e-01,
2.48079254e-01],
[1.43456874e-01, 2.27790562e-01, 1.25732949e+00, 4.39741108e-01,
2.48079254e-01],
[1.50913680e-01, 2.93258751e-01, 1.43550621e+00, 6.55657398e-01,
3.99194379e-01],
[2.41509546e-01, 4.45408842e-01, 1.60328764e+00, 7.91195155e-01,
4.65439861e-01],
[2.41509546e-01, 4.45408842e-01, 3.94855154e+00, 7.91195155e-01,
4.65439861e-01],
[2.79338293e-01, 6.54052129e-01, 4.29487580e+00, 1.12027195e+00,
5.35642929e-01],
[2.79344299e-01, 6.59965244e-01, 4.47781657e+00, 1.47472077e+00,
6.50638813e-01],
[2.79344299e-01, 6.59965244e-01, 4.47781657e+00, 2.15331765e+00,
6.51761649e-01],
[4.08001626e-01, 8.93606884e-01, 4.70345632e+00, 2.32287025e+00,
7.76499905e-01],
[5.06513650e-01, 1.05100248e+00, 4.91174350e+00, 2.57349145e+00,
9.51840954e-01],
[5.06513650e-01, 1.05100248e+00, 4.91178730e+00, 2.58122180e+00,
9.51840954e-01],
[6.26462036e-01, 1.28269152e+00, 5.12224572e+00, 2.65823967e+00,
9.58692172e-01],
[6.26462164e-01, 1.32131699e+00, 5.95439519e+00, 2.74620416e+00,
9.58693576e-01],
[7.13215309e-01, 1.52007822e+00, 6.19287378e+00, 2.93934942e+00,
1.10517416e+00],
[7.13215318e-01, 1.66888175e+00, 6.53449663e+00, 2.93934967e+00,
1.10517416e+00],
[8.25241450e-01, 1.79552434e+00, 6.65547289e+00, 3.03345712e+00,
1.15874248e+00],
[8.33397700e-01, 1.89528376e+00, 6.93623434e+00, 3.37110135e+00,
1.38036646e+00],
[9.36683719e-01, 2.14890549e+00, 7.22137506e+00, 3.59091813e+00,
1.48106671e+00],
[9.36683719e-01, 2.14908847e+00, 7.55258998e+00, 3.93106153e+00,
1.48127267e+00]])
x_points=np.array([-2.55298982, -1.34730371, -0.1416176 , 1.06406851, 2.26975462])
ys = np.cumsum(ys, axis=0)
scale = ys.max() * 2 / 0.8
fig, ax = plt.subplots()
for i in range(4, -1, -1):
y = ys[i, :] / scale
c = plt.get_cmap("coolwarm")(i/4)
plt.fill_between(x_points, -y, y, facecolor=c)
plt.tight_layout()
return fig My actual image includes many more "layers" than this (200, v.s. 5 drawn here), so it ends up becoming almost completely black due to the edges being drawn in. |
Hello, when we are trying to create a baseline for a unit test that uses a scatter plot, we have noticed that pytest-mpl has not been preserving the colormap used in our scatter plot.
For example, the plot we wish to compare against is this:
When we run the unittest through simply doing an import and showing the resulting figure we get the figure above. However, whenever we use pytest to generate the baseline figure, we get the below figure:
Main test:
time_height_scatter routine:
Any help you could provide on this would be appreciated.
The text was updated successfully, but these errors were encountered: