Skip to main content

Draw Bezier curves on your matplotlib plots interactively.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mplbezier-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mplbezier-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file mplbezier-0.1.0.tar.gz.

File metadata

  • Download URL: mplbezier-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for mplbezier-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8d6305da56653fb266544c19d6aebc9e486fe5e6f659bd54a150d77490696d4
MD5 c2686bb7e3a102c02735d00ac90c6430
BLAKE2b-256 e858bcd18f2c21846adc7b8161d88d4305f8be4710b9cbd8d8774b9b912cbf87

See more details on using hashes here.

File details

Details for the file mplbezier-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mplbezier-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for mplbezier-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d137d070b98a560de50e4eb50f09f276e7c1c5fdc8eb86a5b8c7ffcffa1327a1
MD5 c5a2cf4ede5d1429c174fc3c9ab2ff03
BLAKE2b-256 df135a03cf2b7daeae88dc53d3403441d356f0584fff03a43e18320d0727f7f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page