Tutorial 1
[1]:
from maxplotlib import Canvas
%load_ext autoreload
%autoreload 2
[2]:
c = Canvas(width="17cm", ratio=0.5, fontsize=12)
c.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1")
c.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle="dashed", color="red", label="Line 2")
c.show()
[3]:
# You can also explicitly create a subplot and add lines to it
c = Canvas(width="17cm", ratio=0.5, fontsize=12)
sp = c.add_subplot(
grid=True, xlabel="(x - 10) * 0.1", ylabel="10y", yscale=10, xshift=-10, xscale=0.1
)
sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1")
sp.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle="dashed", color="red", label="Line 2")
c.show()
[4]:
# Example with multiple subplots
c = Canvas(width="17cm", ncols=2, nrows=2, ratio=0.5)
sp = c.add_subplot(grid=True)
c.add_subplot(row=1)
sp2 = c.add_subplot(row=1, legend=False)
sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1")
sp2.add_line(
[0, 1, 2, 3], [0, 2, 3, 4], linestyle="dashed", color="red", label="Line 2"
)
c.show()
[5]:
# Test with plotly backend
c = Canvas(width="17cm", ratio=0.5)
sp = c.add_subplot(
grid=True, xlabel="x (mm)", ylabel="10y", yscale=10, xshift=-10, xscale=0.1
)
sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label="Line 1", linestyle="-.")
sp.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle="dashed", color="red", label="Line 2")
c.show()