-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Colorbar is displaced when saving as .eps with bbox_inches='tight' #25176
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
@anntzer did you have time to look at what went wrong here? |
Oops, good catch. The fix is diff --git i/lib/matplotlib/backends/backend_ps.py w/lib/matplotlib/backends/backend_ps.py
index a716859143..86bf4f04b6 100644
--- i/lib/matplotlib/backends/backend_ps.py
+++ w/lib/matplotlib/backends/backend_ps.py
@@ -824,8 +824,8 @@ class FigureCanvasPS(FigureCanvasBase):
def _print_ps(
self, fmt, outfile, *,
- metadata=None, papertype=None, orientation='portrait',
- **kwargs):
+ metadata=None, orientation='portrait', papertype=None,
+ bbox_inches_restore=None, **kwargs):
dpi = self.figure.dpi
self.figure.dpi = 72 # Override the dpi kwarg
@@ -860,7 +860,8 @@ class FigureCanvasPS(FigureCanvasBase):
if mpl.rcParams['text.usetex'] else
self._print_figure)
printer(fmt, outfile, dpi=dpi, dsc_comments=dsc_comments,
- orientation=orientation, papertype=papertype, **kwargs)
+ orientation=orientation, papertype=papertype,
+ bbox_inches_restore=bbox_inches_restore, **kwargs)
def _print_figure(
self, fmt, outfile, *, i.e. _print_ps needs to have an explicit bbox_inches_restore kwarg (due to the implementation of signature sniffing in _switch_canvas_and_get_print_method). I'll try to write up a PR in the coming days, but anyone should feel free to adopt the patch if they can get this in faster. Note that this is actually a regression in 3.6.0 that has been around for the whole 3.6 release cycle, so I guess it's technically not release critical for 3.7, but perhaps still a good idea to fix asap. |
Co-authored-by: Antony Lee <[email protected]> Closes matplotlib#25176
Co-authored-by: Antony Lee <[email protected]> Closes matplotlib#25176
I am experiencing the same problem using inset_axes and
OS: Linux Fedora 37 (Workstation Edition) |
@Hexanders I think your problem is slightly different as it only shows when you include the inset axes. Please open a new issue so that we can track it. |
@rcomer thank you for your quiq response. I will do so immediately. |
Bug summary
I am plotting with
imshow()
and create a colorbar. When saving the figure as .eps withsavefig()
and optionbbox_inches='tight'
, the colorbar (without the spines) is displaced.Code for reproduction
Expected outcome
Colorbar should be placed inside the spines as when using
plt.show()
. Also, saving as .png instead of .eps works correctly.Actual outcome
Additional information
The bug does not happen when using Matplotlib version 5.2.3.
Operating system
Windows 10
Matplotlib version
3.6.3
Matplotlib backend
module://backend_interagg
Python version
3.11.0
The text was updated successfully, but these errors were encountered: