8000 Close clipped paths by mdboom · Pull Request #4186 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Close clipped paths #4186

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 3 commits into from
Mar 4, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Disable miter limit in SVG, PS and Agg backends
  • Loading branch information
mdboom committed Mar 4, 2015
commit 3b63c19d6b51353ffaab4305f624be0e7677f95e
4 changes: 4 additions & 0 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,8 @@ def print_figure_impl():
print("%s translate"%_nums_to_str(xo, yo), file=fh)
if rotation: print("%d rotate"%rotation, file=fh)
print("%s clipbox"%_nums_to_str(width*72, height*72, 0, 0), file=fh)
# Disable any sort of miter limit
print("%s setmiterlimit" % 100000, file=fh)

# write the figure
content = self._pswriter.getvalue()
Expand Down Expand Up @@ -1338,6 +1340,8 @@ def write(self, *kl, **kwargs):
#print >>fh, "gsave"
print("%s translate"%_nums_to_str(xo, yo), file=fh)
print("%s clipbox"%_nums_to_str(width*72, height*72, 0, 0), file=fh)
# Disable any sort of miter limit
print("%d setmiterlimit" % 100000, file=fh)

# write the figure
print(self._pswriter.getvalue(), file=fh)
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ def _write_default_style(self):
writer = self.writer
default_style = generate_css({
'stroke-linejoin': 'round',
'stroke-linecap': 'butt'})
'stroke-linecap': 'butt',
# Disable the miter limit. 100000 seems to be close to
# the maximum that renderers support before breaking.
'stroke-miterlimit': '100000'})
writer.start('defs')
writer.start('style', type='text/css')
writer.data('*{%s}\n' % default_style)
Expand Down
29 changes: 15 additions & 14 deletions lib/matplotlib/tests/test_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
from numpy import ma
import matplotlib
from matplotlib import rc_context
from matplotlib.testing.decorators import image_comparison, cleanup
import matplotlib.pyplot as plt
from matplotlib import rcParams
Expand Down Expand Up @@ -258,27 +259,27 @@ def test_colorbarbase():
baseline_images=['colorbar_closed_patch'],
remove_text=True)
def test_colorbar_closed_patch():
fig = plt.figure(figsize=(8,6))
fig = plt.figure(figsize=(8, 6))
ax1 = fig.add_axes([0.05, 0.85, 0.9, 0.1])
ax2 = fi 8000 g.add_axes([0.1, 0.65, 0.75, 0.1])
ax3 = fig.add_axes([0.05, 0.45, 0.9, 0.1])
ax4 = fig.add_axes([0.05, 0.25, 0.9, 0.1])
ax5 = fig.add_axes([0.05, 0.05, 0.9, 0.1])

cmap = cm.jet
cmap.set_under('w')
cmap.set_over('w')

im = ax1.pcolormesh(np.linspace(0,10,16).reshape((4,4)))
cmap = get_cmap("RdBu", lut=5)

plt.colorbar(im,cax=ax2,cmap=cmap,orientation='horizontal',
extend='both',extendfrac=0.5)
plt.colorbar(im,cax=ax3,cmap=cmap,orientation='horizontal',
extend='both',)
plt.colorbar(im,cax=ax4,cmap=cmap,orientation='horizontal',
extend='both',extendrect=True)
plt.colorbar(im,cax=ax5,cmap=cmap,orientation='horizontal',
extend='neither')
im = ax1.pcolormesh(np.linspace(0, 10, 16).reshape((4, 4)), cmap=cmap)
values = np.linspace(0, 10, 5)

with rc_context({'axes.linewidth': 16}):
plt.colorbar(im, cax=ax2, cmap=cmap, orientation='horizontal',
extend='both', extendfrac=0.5, values=values)
plt.colorbar(im, cax=ax3, cmap=cmap, orientation='horizontal',
extend='both', values=values)
plt.colorbar(im, cax=ax4, cmap=cmap, orientation='horizontal',
extend='both', extendrect=True, values=values)
plt.colorbar(im, cax=ax5, cmap=cmap, orientation='horizontal',
extend='neither', values=values)


if __name__ == '__main__':
Expand Down
3 changes: 3 additions & 0 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ RendererAgg::_draw_path(path_t &path, bool has_clippath, const facepair_t &face,
stroke.width(points_to_pixels(gc.linewidth));
stroke.line_cap(gc.cap);
stroke.line_join(gc.join);
stroke.miter_limit(points_to_pixels(gc.linewidth));
theRasterizer.add_path(stroke);
} else {
dash_t dash(path);
Expand All @@ -425,6 +426,7 @@ RendererAgg::_draw_path(path_t &path, bool has_clippath, const facepair_t &face,
stroke.line_cap(gc.cap);
stroke.line_join(gc.join);
stroke.width(linewidth);
stroke.miter_limit(points_to_pixels(gc.linewidth));
theRasterizer.add_path(stroke);
}

Expand Down Expand Up @@ -564,6 +566,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
stroke.width(points_to_pixels(gc.linewidth));
stroke.line_cap(gc.cap);
stroke.line_join(gc.join);
stroke.miter_limit(points_to_pixels(gc.linewidth));
theRasterizer.reset();
theRasterizer.add_path(stroke);
agg::render_scanlines(theRasterizer, slineP8, scanlines);
Expand Down
0