Repository navigation
API Figure
A Python class for plotting numerical data into graphical figures.
Attributes:
- figsize (tuple[int, int]): Sets the output size of the figure.
Example usage:
import numpy as np
import wplt
X = np.linspace(0, 10, 101)
Y = X**2
fig = wplt.Figure(figsize=(10, 10))
fig.plot(X, Y)
fig.title("Square funcion")
fig.preview()Add plot of coordinates from X and Y. A figure can contain multiple plots, and they all pick a different line or point color.
Parameters:
- X (np.array): Array of x-coordinates.
- Y (np.array): Array of Y-coordinates.
- scatter (bool): Choice of scattering points instead of drawing a line through them.
- label (string): Label to display inside legend.
- width (int): Width of line or diameter width for points.
Usage:
fig.plot(X, Y, label="Plot 1")Show all x-values from x_left to y_right.
Parameters:
- x_left (int): Leftmost range of X-axis.
- x_right (int): Rightmost range of X-axis.
Usage:
fig.crange(-100, 100) # Show x-values from -100 to 100.Show all y-values from y_bottom to y_top.
Parameters:
- y_bottom (int): Bottom range of Y-axis.
- y_top (int): Top range of Y-axis.
Usage:
fig.yrange(-100, 100) # Show y-values from -100 to 100.Displays X-axis on your figure.
Usage:
fig.xaxis()Displays Y-axis on your figure.
Usage:
fig.yaxis()Adds a background grid to your figure. Default is set to strike lines through all integers.
Parameters:
- x_steps (int): Vertical line seperataion.
- y_steps (int): Horizontal line seperataion.
Usage:
fig.grid(x_steps=10, y_steps=100) # Horizontal lines every 100 steps, and vertical lines every 10 steps.Adds a legend to the top left of your figure. This requires you to add labels to one or more of your plots.
Usage:
fig.legend()Adds a title to the top of your figure.
Parameters:
- title_text (string): Title to display.
Usage:
fig.title("Figure title")Previews a figure with plots added to it. Not available for video (i.e. when using TimeSeries).
Usage:
fig.preview()Saves a figure to file. Either png for static plots, and gif for plots with
Parameters:
- path (string): Filepath to where to save image. Leave empty for default.
Usage:
fig.save("C:/image.png")