Skip to content

backend_pgf: don't clip filled paths (fixes #2885, #3935, #3693) #4248

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

Merged
merged 1 commit into from
Mar 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pep8 is complaining about one too many blank lines here.

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