Skip to content

Commit c811acb

Browse files
committed
fixes on MixedModeRenderer for non-72dpi figures
1 parent b25e506 commit c811acb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/backends/backend_mixed.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
4848
# the figure dpi before and after the rasterization. Although
4949
# this looks ugly, I couldn't find a better solution. -JJL
5050
self.figure=figure
51+
self._figdpi = figure.get_dpi()
5152

5253
self._bbox_inches_restore = bbox_inches_restore
5354

@@ -121,16 +122,19 @@ def stop_rasterizing(self):
121122
image.is_grayscale = False
122123
image.flipud_out()
123124
gc = self._renderer.new_gc()
125+
# TODO: If the mixedmode resolution differs from the figure's
126+
# dpi, the image must be scaled (dpi->_figdpi). Not all
127+
# backends support this.
124128
self._renderer.draw_image(
125129
gc,
126-
float(l)/self.dpi*72.,
127-
(float(height) - b - h)/self.dpi*72.,
130+
float(l) / self.dpi * self._figdpi,
131+
(float(height)-b-h) / self.dpi * self._figdpi,
128132
image)
129133
self._raster_renderer = None
130134
self._rasterizing = False
131135

132-
# restore the figure dpi.
133-
self.figure.set_dpi(72)
136+
# restore the figure dpi.
137+
self.figure.set_dpi(self._figdpi)
134138

135139
if self._bbox_inches_restore: # when tight bbox is used
136140
r = process_figure_for_rasterizing(self.figure,

0 commit comments

Comments
 (0)