A data-analysis-oriented library for drawing beautiful plots.
This library makes heavy use of the matplotlib
library, therefore it is necessary to have some
understanding of that library.
Shortly, Plotter makes it easy to create beautiful matplotlib
plots by generating instances of
matplotlib object with preset values. In other words, it gives the user a faster and easier way of
rendering plots of analyzed data.
Follow the steps below to install Plotter (Unix-like systems):
-
Clone the repository to a directory in your system.
-
Open the terminal and navigate to said folder.
-
Run the command
python3 -m install
-
A dist directory will be created, containing a .whl file.
-
To install the package run
pip3 install /path/to/whl/file
-
If the installation was successful, Plotter can be imported simply by
import plotter as p
Note: It is possible that the commands to use are python
and pip
, instead of, respectively, python3
and pip3
.
Once imported, the library will create a tree of directories with the following structure:
plotter
├── img
├── log
├── text
└── utils
├── blueprint.txt
├── log_config.json
├── style.mplstyle
└── text_example.json
These directories/files, which are not to be deleted, have the following purposes:
- The /img directory is the one where the plots are saved to.
- The /log directory is the one where the log files are stored.
- The /text directory is the one where the json files containing the plot text are to be stored.
- The /utils directory stores useful files, in particular:
- blueprint.txt, which contains boilerplate code needed for a basic example;
- log_config.json, which contains the logging configurations;
- style.mplstyle, which contains the matplotlib configurations;
- text_example.json, which is the blueprint for the json files to put in the /text directory.
For a basic graph, try the following piece of code.
import numpy as np
import plotter as p
# datasets to plot
x = np.linspace(-5, 5, num=50)
y = x**2
y_err = np.full(50, 0.5)
x_err = np.full(50, 0.2)
# function to plot
def f(x):
return x**2
# create canvas
canvas = p.Canvas("prova.json")
canvas.setup()
# add scatter plot and 1D graph to canvas
p.ScatterPlot(x, y, y_err, x_err).draw(canvas)
p.Plot(x, f, (0.01, 0.01)).draw(canvas)
# render plot
canvas.end()
See the LICENCE file for licence rights and limitations.