Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Pyfigure98

A python package to create plots and figures easily

GitHub Release Date - Published_At GitHub commit activity (branch) GitHub issues

PyPI - Version PyPI - License

If you have ever tried to make figures in python, you may have faced the same issues that annoyed me: a lot of copy/pasting between projects, countless hours spent on the internet searching for how to change the size of this or that thing again ? and always searching for specific things like axes formated specifficaly for angles, logarithms, times, ...

With this project, no more hurdles.


Features

This project is based on matplotlib and contains many methods to facilitate the creation of complex figures. Here is a non-exaustive list of its functionalities:

  • Hability to put multiple charts on a single figure.
  • Hability to have more than one y-axis.
  • Hability to format the x-axis to measure time, angles and logarithmic scales.
  • Hability to format de y-axis to measure angles and logarithmic scales.
  • Automated and unified font sizes, defined in templates.
  • And many more !

Documentation

Installation

To install this package using pip, simply run

pip install pyfigure98

Usage

In order to use this package, create a new Figure object, and add a new figure to it:

    from pyfigure98 import Figure
    import numpy as np # Used later
    
    myNewFigure = Figure()
    myNewFigure.addFigure(template="default", rows=1, cols=1)

For more informations on how to use the template variable and how to modify templates, see section.

Next, you can add a new chart to your newly-created figure:

chartOfMyNewFigure = myNewFigure.addchart("myChart")

Modify the x-axis and y-axis by using these methods:

chartOfMyNewFigure.setAxisX(x_min=-10, x_max=10, label="x")
chartOfMyNewFigure.setAxisY(y_min=-5, y_max=10, label="f(x)")

Add a plot by using:

x = np.arange(-10, 10, 0.2)
y = (0.3*x)**3
chartOfMyNewFigure.plotStandard(x=x, y=y, label="example with f(x)=0.3*x^3", color="red")

Don't forget to add a title and a legend !

myNewFigure.setTitle("My figure")
chartOfMyNewFigure.setTitle("my chart")
chartOfMyNewFigure.setLegend()

Finally, save you figure:

myNewFigure.figSave('myfig')

After all these steps, you should obtain this:

This example is, of course, trivial. But it illustrates the basic principles of this package.

Of course, there are many more methods available !

Templates

As explained before, the templates are responsible for the unified font sizes and colors (WIP) across different figures.

Usage

To use a template, simply specify the name of the name.json like in the usage example described here.

Add a custom template

Custom templates are supported as well. In order to create and use a custom template, proceed as follow:

from pyfigure98 import Figure

myNewFigure = Figure()

myNewFigure.addCustomTemplate("custom")  
myNewFigure.addFigure(template="custom", rows=1, cols=1)

Here, the custom template file used is custom.json. This file must be located in the same directory as the python script calling that function. So in this example, the structure is as followed:

├── myproject
│   ├── figurewithcustomtemplate.py
│   ├── custom.json

Write a custom template

The template needs to be a .json file with a specific structure.

Here you can see the default template file structure.
{
    "fig_size_x": 11,
    "fig_size_y": 8,
    "label_size": 25,
    "tick_size": 20,
    "legend_size": 20,
    "in_text_size": 20,
    "subplot_title_size": 30,
    "fig_title_size": 35,
    "markersize": 10,
    "tick_width_major": 2.25,
    "tick_length_major": 5,
    "tick_width_minor": 1.75,
    "tick_length_minor": 3   
}

Code inside default.json.

As you can see, each property has a corresponding value and represents a certain element in a plot. At the end of this section, a table will give you all the different properties and corresponding default values, as well as a description of what these values are used for.

If a property is not specified in the custom template.json, its value will be determined by the one defined in default.json. This way, you do not need to specify every properties in your custom file if you only want to change a few of them.

Here is an overview of all the different template variables and their default value.
Syntax Default value Description
"fig_size_x" 11
"fig_size_y" 8
"label_size" 25
"tick_size" 20
"legend_size" 20
"in_text_size" 20
"subplot_title_size" 30
"fig_title_size" 35
"markersize" 10
"tick_width_major" 2.25
"tick_length_major" 5
"tick_width_minor" 1.75
"tick_length_minor" 3

Examples


Metadata

Release files for pyfigure98 1.1.1

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

Source distribution (sdist)

Source distribution for pyfigure98 1.1.1
File Size Uploaded Provenance Actions
pyfigure98-1.1.1.tar.gz 13.9 kB Without provenance Details for pyfigure98-1.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 28.4 kB

Release files / pyfigure98-1.1.1.tar.gz

Download URL pyfigure98-1.1.1.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b4fcf8038c434856c074286eaede448479b8e8ce8875e200e370b344a91b940e
BLAKE2b-256 checksum
How to use checksums
c431c4f3ae41b4dd1b88c98b00b757e51545c3e041bc9c9c42186ea68a603dc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / pyfigure98-1.1.1-py3-none-any.whl

Download URL pyfigure98-1.1.1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7a43095d3be8718dab1f50f89745479600bf98ed4e53054561c5911d0ef2233
BLAKE2b-256 checksum
How to use checksums
75c68889b5a07251ebf12212d93b3d86d43a8a6d2525dd80789f1091d4cf38e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Security for pyfigure98 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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