
( ec and fc are edge colour and fill colour zorder determines the artist order.
Clip box powerviolence blogspot Patch#
But what you want to achieve can be done much more easily, using a FancyBboxPatch (a Rectangle patch would work just as well): from matplotlib.patches import FancyBboxPatchĪx.add_patch(FancyBboxPatch((bb.xmin, bb.ymin), bb.width, bb.height, boxstyle="square",

I would be happy to hear from someone who knows more about Bboxes why your Bbox acts the way it does. It seems that these involve transformations between different sets of co-ordinates in the case of a regular Axes it is between x- and y-values, pixels, and the specific adaptations to screen size. The set_clip_box method you refer to has not got very helpful documentation, and the examples of its use both use the bbox of an Axes, which is a nested transformation ie _, ax = plt.subplots() ax.bbox is a TransformedBbox based on a linear transform of another TransformedBbox based on an Affine2D transform of a plain Bbox! (All of this explained in more detail here.) I've spent some time reading about Bboxes in Matplotlib and they are pretty complicated. Print(boundingbox, '\n', boundingbox.extents) # 178.0 is 2 * dpi, I believe the doubling happens because of what screen I have gotīoundingbox = om_extents() Line_b, = ax.plot(x, y, color='red', linewidth=3.0) Line_a, = ax.plot(x, y, color='red', linewidth=3.0) Using 'none' color for its facecolor could be more convenient because it's figure style-independent. It's indeed much simpler to use a Rectangle or Polygon to specify the clip box because they can be added to axes.


When we print ax.bbox, we can see that its size is to be specified in pixels. Since we don't add the Bbox instance to any axes when we create, it could only be relative to the figure. Finding its extent tells us what units should be used to specify the clip box Bbox. The "natural" clip box for the right hand side plot is ax.bbox.
