Skip to content

Fix single pixel markers #695

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 6 commits into from
Feb 29, 2012
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
Next Next commit
Another attempt at getting pixel markers to work correctly.
  • Loading branch information
mdboom committed Feb 29, 2012
commit 752ad0e3203da53d1730e5d73e5ee057f68e553b
5 changes: 4 additions & 1 deletion lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,11 @@ def draw(self, renderer):
marker_path = marker.get_path()
marker_trans = marker.get_transform()
w = renderer.points_to_pixels(self._markersize)
if marker.get_marker() != ',': # Don't scale for pixels
if marker.get_marker() != ',':
# Don't scale for pixels, and don't stroke them
marker_trans = marker_trans.scale(w)
else:
gc.set_linewidth(0)
renderer.draw_markers(
gc, marker_path, marker_trans, subsampled, affine.frozen(),
rgbFace)
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,8 @@ def _set_circle(self, reduction = 1.0):

def _set_pixel(self):
self._path = Path.unit_rectangle()
self._transform = Affine2D().translate(-0.5, -0.5) \
.scale(0.5, 0.5).translate(0.5, 0.5)
self._transform = Affine2D().translate(-0.49999, -0.50001)
Copy link
Member

Choose a reason for hiding this comment

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

If anything deserves a comment, this does. This just doesn't give me any sort of "warm fuzzies"....

Copy link
Member Author

Choose a reason for hiding this comment

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

Just added a comment in a new commit.

self._snap_threshold = False
self._joinstyle = 'miter'

def _set_point(self):
self._set_circle(reduction = self._point_size_reduction)
Expand Down
2 changes: 1 addition & 1 deletion src/_backend_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ RendererAgg::draw_markers(const Py::Tuple& args)
// Deal with the difference in y-axis direction
marker_trans *= agg::trans_affine_scaling(1.0, -1.0);
trans *= agg::trans_affine_scaling(1.0, -1.0);
trans *= agg::trans_affine_translation(0.5, (double)height+0.5);
trans *= agg::trans_affine_translation(0.0, (double)height);

PathIterator marker_path(marker_path_obj);
transformed_path_t marker_path_transformed(marker_path, marker_trans);
Expand Down