Skip to content

get_tightbbox doesn't account for markeredgewidth #16606

@brunobeltran

Description

@brunobeltran

Simple to solve problem, making issue just to refer to it in the PR.

Bug report

For lines, Axes.get_tightbbox relies on Line2D.get_window_extent, which computes extra padding due to markers as

ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5

but this can cut off half of the marker edge.

This phenomena which is only visible if you have a line that extends outside of a plot, and has markeredgewidth > 1. For simple markers, (like 'S', 'O'), the code should instead read

extra_pts = self._markersize + self._markeredgewidth
ms = (extra_pts / 72.0 * self.figure.dpi) * 0.5

I'll edit this shortly to include code that reproduces the bug, after I document for all the common markers what the expected behavior should be.

Matplotlib version

  • Operating system: Linux
  • Matplotlib version: 3.2.0rc2.post1594.dev0+gead45c7e6
  • Matplotlib backend: module://ipykernel.pylab.backend_inline`
  • Python version: 3.7.3
    MPL installed from Github, Python is miniconda.

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions