Skip to content

lmarchetti02/plotter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plotter

A data-analysis-oriented library for drawing beautiful plots.

Description

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.

Installation

Follow the steps below to install Plotter (Unix-like systems):

  1. Clone the repository to a directory in your system.

  2. Open the terminal and navigate to said folder.

  3. Run the command

    python3 -m install
  4. A dist directory will be created, containing a .whl file.

  5. To install the package run

    pip3 install /path/to/whl/file
  6. 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.

Usage

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:

  1. The /img directory is the one where the plots are saved to.
  2. The /log directory is the one where the log files are stored.
  3. The /text directory is the one where the json files containing the plot text are to be stored.
  4. 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.

Example

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()

Images

example1 example2

License

See the LICENCE file for licence rights and limitations.

About

A small Python library for plotting beautiful graphs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages