-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
3D Scatter Plot with Colorbar is not saved correctly with savefig #18885
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
Comments
Is there any somewhat simple workaround? Aside from just downgrading? |
Um, probably not.
This is a good hint: In fact, I can break the example without the colorbar by adding We need to find a way to do the color updates therein consistently with coloring and reordering in |
Since we always recalculate on draw, I suggest something like: 6c0c30b applied to all 3D artists. |
I do not understand why the output from inline (which is under the hood calling savefig!) works... |
To answer my own question, it is because of the |
Well, that was fun to track down! See the long docstring on the helper in #18929 if you are interested. In short, |
Bug report
Bug summary
When saving a 3D scatter plot with a color bar using
savefig
(eitherplt.savefig
orfig.savefig
), the data point colors are incorrect on the saved image, however the inline image (I'm using jupyter lab notebooks) is fine, the issue is only present when saving the figure. Note that this only happens when a colorbar is added to the figure, when a figure with points colored according to a set of values is saved, the issue does not occur. So it would seem that this issue is caused by some interaction of savefig and colorbar.I've tried both matplotlib version 3.3.1 and 3.3.2 and in both versions this occurs. I've also tried downgrading to version 3.2.1, in version 3.2.1 this does not occur, so it seems some change in 3.3.1 is the cause of this issue.
Code for reproduction
Requirements: matplotlib 3.3.1 or 3.3.2
The following requirements are purely for setting up an example dataset which I used in the following code snippet to generate an example dataset to plot, as such I'm not listing the version numbers.
Optional: pandas, numpy
Also note that I used JupyterLab notebook to run the code, although given that I was able to 'fix' the issue by downgrading to matplotlib version 3.2.1 I don't think there is any link between running the code in JupyterLab and the issue itself.
Actual outcome
This is being the saved figure with a color bar (note that if you zoom in the outlines of the data points are correct - see expected outcome below - but the fill of the points is incorrect).
Note that if no colorbar is added, the plot saves correctly as shown below.
Expected outcome
This is a screenshot of the colorbar chart as it is shown inline in the JupyterLab notebook.
And this is a screenshot of the non colorbar chart as it is shown inline in the JupyterLab notebook, note this one is essentially the exact same as the saved version, so the issue is purely with the colorbar/savefig interaction.
Matplotlib version
print(matplotlib.get_backend())
):Everything has been installed via conda, with all packages listed being install from the default channel.
The text was updated successfully, but these errors were encountered: