Skip to content

Quickstart

Install

From the project root:

pip install .

Create A Workspace

Call plotter.setup_workspace() in the directory where you want Plotter to place runtime assets. It creates folders for generated images, logs, text files, and bundled helper resources.

import plotter as p

p.setup_workspace()

Add Plot Text

Canvas text comes from JSON files in plotter/text. Each subplot entry can define axis labels, a title, and drawable labels:

[
  {
    "title": "Example",
    "x_label": "x",
    "y_label": "y",
    "scatter_plots": ["data"],
    "line_plots": ["model"],
    "bar_charts": [""],
    "histograms": [""]
  }
]

Draw

import numpy as np
import plotter as p

x = np.linspace(0, 10, 100)

with p.Canvas("example.json", show=False, save="example.png") as canvas:
    canvas.setup(xlim=(0, 10), ylim=(-1.2, 1.2))
    p.FunctionPlot(x, np.sin).draw(canvas, color="darkgreen", label="sin(x)")
    canvas.draw_line("h", point=0, linestyle="--")

Plotter example

Custom Layouts

rows_cols=(n_rows, n_cols) gives a regular grid. For anything else, pass layout= a mosaic of plot_n indices instead: repeating an index makes that subplot span several cells, and None leaves a cell empty. The JSON file needs one entry per distinct subplot. sharex/sharey (True, "row", or "col") link the subplots' axes, hiding the redundant tick labels.

# subplots 0 and 1 stacked on the left, sharing x; subplot 2 spanning the right column
with p.Canvas("layout.json", layout=[[0, 2], [1, 2]], width_ratios=(1, 1.5), sharex="col") as canvas:
    canvas.setup()
    ...