Skip to content

Commit

Permalink
Merge pull request #4248 from pwuertz/fix_2885
Browse files Browse the repository at this point in the history
FIX : backend_pgf: don't clip filled paths 

fixes #2885, fixes #3935, fixes #3693
  • Loading branch information
tacaswell committed Mar 19, 2015
2 parents d281296 + 3f80c70 commit 71ba6ff
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/matplotlib/backends/backend_pgf.py
Expand Up @@ -478,7 +478,7 @@ def draw_path(self, gc, path, transform, rgbFace=None):
# draw the path
self._print_pgf_clip(gc)
self._print_pgf_path_styles(gc, rgbFace)
self._print_pgf_path(gc, path, transform)
self._print_pgf_path(gc, path, transform, rgbFace)
self._pgf_path_draw(stroke=gc.get_linewidth() != 0.0,
fill=rgbFace is not None)
writeln(self.fh, r"\end{pgfscope}")
Expand Down Expand Up @@ -584,11 +584,11 @@ def _print_pgf_path_styles(self, gc, rgbFace):
dash_str += r"}{%fpt}" % dash_offset
writeln(self.fh, dash_str)

def _print_pgf_path(self, gc, path, transform):
def _print_pgf_path(self, gc, path, transform, rgbFace=None):
f = 1. / self.dpi
# check for clip box
# check for clip box / ignore clip for filled paths
bbox = gc.get_clip_rectangle() if gc else None
if bbox:
if bbox and (rgbFace is None):
p1, p2 = bbox.get_points()
clip = (p1[0], p1[1], p2[0], p2[1])
else:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 13 additions & 1 deletion lib/matplotlib/tests/test_backend_pgf.py
Expand Up @@ -73,16 +73,28 @@ def compare_figure(fname, savefig_kwargs={}):
def create_figure():
plt.figure()
x = np.linspace(0, 1, 15)

# line plot
plt.plot(x, x ** 2, "b-")

# marker
plt.plot(x, 1 - x**2, "g>")

# filled paths and patterns
plt.fill_between([0., .4], [.4, 0.], hatch='//', facecolor="lightgray",
edgecolor="red")
plt.plot(x, 1 - x**2, "g>")
plt.fill([3, 3, .8, .8, 3], [2, -2, -2, 0, 2], "b")

# text and typesetting
plt.plot([0.9], [0.5], "ro", markersize=3)
plt.text(0.9, 0.5, 'unicode (ü, °, µ) and math ($\\mu_i = x_i^2$)',
ha='right', fontsize=20)
plt.ylabel('sans-serif, blue, $\\frac{\\sqrt{x}}{y^2}$..',
family='sans-serif', color='blue')

plt.xlim(0, 1)
plt.ylim(0, 1)


# test compiling a figure to pdf with xelatex
@switch_backend('pgf')
Expand Down

0 comments on commit 71ba6ff

Please sign in to comment.