Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d40e581

Browse files
author
Steve Chaplin
committed
SC
svn path=/trunk/matplotlib/; revision=1464
1 parent 1e9cfd6 commit d40e581

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-06-15 backend_cairo.py: updated to use pycairo 0.5.0 - SC
4+
35
2005-06-14 Wrote some GUI neutral widgets (Button, Slider,
46
RadioButton) in matplotlib.widgets. See examples/widgets -
57
JDH

lib/matplotlib/backends/backend_cairo.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ def new_figure_manager(num, *args, **kwargs): # called by backends/__init__.py
524524

525525
def print_figure_fn(figure, filename, dpi=150, facecolor='w', edgecolor='w',
526526
orientation='portrait'):
527-
#if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
528527
if _debug: print _fn_name()
529528

530529
# settings for printing
@@ -588,26 +587,25 @@ def _save_ps_pdf (figure, filename, ext, orientation):
588587
# Cairo produces PostScript Level 3
589588
# 'ggv' can't read cairo ps files, but 'gv' can
590589

591-
ppi = 200.0 # not currently used
592-
#figure.dpi.set(72)
593-
figure.dpi.set(96) # Cairo uses 96 dpi
594-
590+
dpi = 72
591+
figure.dpi.set (dpi)
595592
w_in, h_in = figure.get_size_inches()
596-
width, height = figure.get_width_height()
593+
width_in_points, height_in_points = w_in * dpi, h_in * dpi
597594

598595
if orientation == 'landscape':
599-
w_in, h_in = h_in, w_in
600-
# TODO - change width, height
596+
width_in_points, height_in_points = height_in_points, width_in_points
601597

602598
if ext == 'ps':
603-
surface = cairo.PSSurface (filename, width, height)
599+
surface = cairo.PSSurface (filename, width_in_points, height_in_points)
604600
else: # pdf
605-
surface = cairo.PDFSurface (filename, width, height)
601+
surface = cairo.PDFSurface (filename, width_in_points,
602+
height_in_points)
603+
# surface.set_dpi() can be used
606604
ctx = cairo.Context (surface)
607605

608606
if orientation == 'landscape':
609-
ctx.rotate(numx.pi/2)
610-
ctx.translate(0, -height)
607+
ctx.rotate (numx.pi/2)
608+
ctx.translate (0, -height_in_points)
611609
# cairo/src/cairo_ps_surface.c
612610
# '%%Orientation: Portrait' is always written to the file header
613611
# '%%Orientation: Landscape' would possibly cause problems
@@ -616,14 +614,14 @@ def _save_ps_pdf (figure, filename, ext, orientation):
616614
# add portrait/landscape checkbox to FileChooser
617615

618616
renderer = RendererCairo (figure.dpi)
619-
renderer._set_width_height(width, height)
617+
renderer._set_width_height (width_in_points, height_in_points)
620618
renderer.surface = ctx.get_target()
621-
figure.draw(renderer)
619+
figure.draw (renderer)
622620

623621
show_fig_border = False # for testing figure orientation and scaling
624622
if show_fig_border:
625623
ctx.new_path()
626-
ctx.rectangle(0, 0, width, height)
624+
ctx.rectangle(0, 0, width_in_points, height_in_points)
627625
ctx.set_line_width(4.0)
628626
ctx.set_source_rgb(1,0,0)
629627
ctx.stroke()

0 commit comments

Comments
 (0)