Skip to main content

mathsvg

A Python library to draw mathematical objects. Create figures and diagrams and save them as SVG files.

The complete documentation is available at: https://mathsvg.readthedocs.io. The sources are hosted on GitHub: https://github.com/alexn11/mathsvg.

Programs such as Inkscape are great for creating vector graphics. But Inkscape is made more for designer rather than for mathematicians. The process of doing mathematical diagrams and illustrations using Inkscape can sometimes be quite frustrating. Making a python script to produce the content of an SVG file can be a faster solution.

The role of mathsvg is to help with the process of producing your own SVG diagrams using Python scripts. For that purpose a class SvgImage is defined which contains many usefull routines that simplify the creation of mathematical figures with precise descriptions.

Once the mathsvg package and all its dependencies are installed it can be used as a normal Python package.

Here is an example for the creation of a very simple image:

import mathsvg
image = mathsvg.SvgImage(pixel_density = 100, view_window = (( -1, -1 ), ( 1, 1 )))
image.draw_circle([0, 0], 1.1)
image.save("simple-example.svg")

The above program does the following.

After importing the package mathsvg, a SvgImage object is created. The parameters of the constructors are the pixel density (number of pixel per unit of length) and the view window which selects the part of the plane that will be rendered in the image. The coordinates of mathematical objects will be automatically be converted into coordinates on the SVG canvas.

A circle with center (0, 0) and radius 1.1 is drawn using the default drawing options (black solid stroke). Some points of the circle won't appear in the image since they are outside the canvas.

Finally the image is saved in a file with the name "simple-example.svg".

Release files for mathsvg 0.3.4

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

Source distribution (sdist)

Source distribution for mathsvg 0.3.4
File Size Uploaded
mathsvg-0.3.4.tar.gz 14.6 kB Details

Built distribution (wheel)

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

Total release size: 31.6 kB

Release files / mathsvg-0.3.4.tar.gz

Download URL mathsvg-0.3.4.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a180127a0968b70c02c49156e740a88fa24e0ae8f08765a5d4520aed15078ee3
BLAKE2b-256 checksum
How to use checksums
972a0b95b216dd0555bc9e100ee1fa900ab928e93b5f4e9c9e9a4d85581a752c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.3

Release files / mathsvg-0.3.4-py3-none-any.whl

Download URL mathsvg-0.3.4-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce726af7091701d04fb9873a84baf490c1c1bd509a7c0b8f39d05c30276f2e36
BLAKE2b-256 checksum
How to use checksums
730fdc03135a150215202e5c7b1cf2b1b0397d028e36b29ce5badfc4cac6eab0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.3

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.6

2 release files

0.3.5

2 release files

This release

0.3.4 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

1 release file

0.0.1

2 release files

0.0.0

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