Skip to content

margins does not handle bézier curves #7184

@anntzer

Description

@anntzer

2.0b4, example modified from http://matplotlib.org/users/path_tutorial.html#bezier-example

import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches

verts = [
    (0., 0.),  # P0
    (0.2, 1.), # P1
    (1., 0.8), # P2
    (0.8, 0.), # P3
    ]

codes = [Path.MOVETO,
         Path.CURVE4,
         Path.CURVE4,
         Path.CURVE4,
         ]

path = Path(verts, codes)

fig, axs = plt.subplots(2)

patch = patches.PathPatch(path, facecolor='none', lw=2)
axs[0].add_patch(patch)
xs, ys = zip(*verts)
axs[0].plot(xs, ys, 'x--', lw=2, color='black', ms=10)

patch = patches.PathPatch(path, facecolor='none', lw=2)
axs[1].add_patch(patch)

plt.show()

figure_1

Note how the bottom axes have their limits set as if using the positions of the bézier control points (on the unit square), with no margins.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy