Skip to content

Commit 206b775

Browse files
committed
fixed pixel border bug for composite images (eg layer_image.py)
svn path=/trunk/matplotlib/; revision=5611
1 parent a17ce52 commit 206b775

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

MANIFEST.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ include lib/matplotlib/mpl-data/fonts/ttf/*
1414
include lib/matplotlib/mpl-data/fonts/pdfcorefonts/*
1515
include lib/matplotlib/mpl-data/fonts/afm/*
1616
recursive-include license LICENSE*
17-
recursive-include examples README *.py
18-
prune examples/_tmp_*
17+
recursive-include examples *
18+
recursive-include doc *
1919
recursive-include src *.cpp *.c *.h
2020
recursive-include CXX *.cxx *.hxx *.c *.h
2121
recursive-include agg24 *

examples/api/mathtext_asarray.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,20 @@
55
import numpy as np
66
import matplotlib.mathtext as mathtext
77
import matplotlib.pyplot as plt
8+
import matplotlib
9+
matplotlib.rc('image', origin='upper')
810

911
parser = mathtext.MathTextParser("Bitmap")
1012

1113
parser.to_png('test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100)
1214

1315

14-
rgba = parser.to_rgba(r'IQ: $\sigma_i=15$', color='blue', fontsize=20, dpi=200)
16+
rgba1, depth1 = parser.to_rgba(r'IQ: $\sigma_i=15$', color='blue', fontsize=20, dpi=200)
17+
rgba2, depth2 = parser.to_rgba(r'some other string', color='red', fontsize=20, dpi=200)
1518

1619
fig = plt.figure()
17-
fig.figimage(rgba.astype(float)/255., 100, 100)
20+
fig.figimage(rgba1.astype(float)/255., 100, 100)
21+
fig.figimage(rgba2.astype(float)/255., 100, 300)
22+
1823

1924
plt.show()
File renamed without changes.

lib/matplotlib/axes.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1436,15 +1436,18 @@ def draw(self, renderer=None, inframe=False):
14361436
for im in self.images if im.get_visible()]
14371437

14381438

1439-
im = mimage.from_images(self.bbox.height*mag,
1440-
self.bbox.width*mag,
1439+
l, b, r, t = self.bbox.extents
1440+
width = mag*((round(r) + 0.5) - (round(l) - 0.5))
1441+
height = mag*((round(t) + 0.5) - (round(b) - 0.5))
1442+
im = mimage.from_images(height,
1443+
width,
14411444
ims)
14421445
im.is_grayscale = False
14431446
l, b, w, h = self.bbox.bounds
14441447
# composite images need special args so they will not
14451448
# respect z-order for now
14461449
renderer.draw_image(
1447-
l, b, im, self.bbox,
1450+
round(l), round(b), im, self.bbox,
14481451
self.axesPatch.get_path(),
14491452
self.axesPatch.get_transform())
14501453

lib/matplotlib/figure.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ def draw(self, renderer):
796796

797797
if len(self.images)<=1 or renderer.option_image_nocomposite() or not allequal([im.origin for im in self.images]):
798798
for im in self.images:
799+
print 'drawing', im
799800
im.draw(renderer)
800801
else:
801802
# make a composite image blending alpha
@@ -809,8 +810,12 @@ def draw(self, renderer):
809810
ims)
810811
im.is_grayscale = False
811812
l, b, w, h = self.bbox.bounds
813+
clippath, affine = self.get_transformed_clip_path_and_affine()
814+
print 'compodite'
815+
print 'clippath', affine
816+
print 'affine', affine
812817
renderer.draw_image(l, b, im, self.bbox,
813-
*self.get_transformed_clip_path_and_affine())
818+
clippath, affine)
814819

815820
# render the axes
816821
for a in self.axes: a.draw(renderer)

0 commit comments

Comments
 (0)