Skip to content

Draw markers around center of pixels #5603

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 2 commits into from
Dec 3, 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
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/marker_edges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_text/text_contains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/_backend_agg.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ inline void RendererAgg::draw_markers(GCAgg &gc,

// 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);

Expand All @@ -527,6 +528,13 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
points_to_pixels(gc.linewidth));
curve_t marker_path_curve(marker_path_snapped);

if (!marker_path_snapped.is_snapping()) {
// If the path snapper isn't in effect, at least make sure the marker
// at (0, 0) is in the center of a pixel. This, importantly, makes
// the circle markers look centered around the point they refer to.
marker_trans *= agg::trans_affine_translation(0.5, 0.5);
}

transformed_path_t path_transformed(path, trans);
nan_removed_t path_nan_removed(path_transformed, false, false);
snap_t path_snapped(path_nan_removed, SNAP_FALSE, path.total_vertices(), 0.0);
Expand Down