Skip to main content

mplbezier

This module allows you to draw Bezier curves interactively in matplotlib and load them again afterwards. Install it by cloning the git repository, navigating into the repository root directory and typing into the console:

pip install .

Simply import Bezier from mplbezier and create a new Bezier object, which you pass both the Axis and a filename of a pickle file to store the anchor point data. Using Bezier.enable, you enable the interactive drawing mode. In order to use the interactive drawing mode, you need to be inside an interactive matplotlib backend, such as qtagg. If you are using this module from a Jupyter notebook, switch to interactive mode using magic commands such as %matplotlib Qt at the top of the cell.

import matplotlib.pyplot as plt
from mplbezier import Bezier

fig, ax = plt.subplots()

b = Bezier(ax, 'my_curve.pkl')
b.enable()

plt.show()

By clicking with the left mouse button inside the plot, you will generate a new anchor point. By clicking on an anchor point, you can reveal the handles with which you can define the position of the control points. By dragging a point, you can move it on the axis. By right clicking a point, you can remove it from the Bezier curve. If the point lies between two other points, the curve will automatically connect the two surrounding points with each other. Moreover, "ctrl+z" is supported to undo your last action.

Once you are satisfied with your curve, you can remove or comment out the line b.enable(). This will remove the anchor points from the curve, thereby giving you the final plot.

The curve can be initialized with three keyword arguments:

  • c sets the color (default 'black')
  • lw sets the linewidth (default 1)
  • ls sets the linestyle (default ('-')

img.png

Metadata

Release files for mplbezier 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mplbezier 0.1.0
File Size Uploaded
mplbezier-0.1.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mplbezier 0.1.0
File Interpreter ABI Platform
mplbezier-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / mplbezier-0.1.0.tar.gz

Download URL mplbezier-0.1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d8d6305da56653fb266544c19d6aebc9e486fe5e6f659bd54a150d77490696d4
BLAKE2b-256 checksum
How to use checksums
e858bcd18f2c21846adc7b8161d88d4305f8be4710b9cbd8d8774b9b912cbf87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / mplbezier-0.1.0-py3-none-any.whl

Download URL mplbezier-0.1.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d137d070b98a560de50e4eb50f09f276e7c1c5fdc8eb86a5b8c7ffcffa1327a1
BLAKE2b-256 checksum
How to use checksums
df135a03cf2b7daeae88dc53d3403441d356f0584fff03a43e18320d0727f7f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page