{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "\n", "# Tutorial 1\n" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "from maxplotlib import Canvas\n", "\n", "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "c = Canvas(width=\"17cm\", ratio=0.5, fontsize=12)\n", "c.add_line([0, 1, 2, 3], [0, 1, 4, 9], label=\"Line 1\")\n", "c.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle=\"dashed\", color=\"red\", label=\"Line 2\")\n", "c.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "# You can also explicitly create a subplot and add lines to it\n", "\n", "c = Canvas(width=\"17cm\", ratio=0.5, fontsize=12)\n", "sp = c.add_subplot(\n", " grid=True, xlabel=\"(x - 10) * 0.1\", ylabel=\"10y\", yscale=10, xshift=-10, xscale=0.1\n", ")\n", "\n", "sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label=\"Line 1\")\n", "sp.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle=\"dashed\", color=\"red\", label=\"Line 2\")\n", "c.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "# Example with multiple subplots\n", "\n", "c = Canvas(width=\"17cm\", ncols=2, nrows=2, ratio=0.5)\n", "sp = c.add_subplot(grid=True)\n", "c.add_subplot(row=1)\n", "sp2 = c.add_subplot(row=1, legend=False)\n", "sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label=\"Line 1\")\n", "sp2.add_line(\n", " [0, 1, 2, 3], [0, 2, 3, 4], linestyle=\"dashed\", color=\"red\", label=\"Line 2\"\n", ")\n", "c.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "# Test with plotly backend\n", "c = Canvas(width=\"17cm\", ratio=0.5)\n", "sp = c.add_subplot(\n", " grid=True, xlabel=\"x (mm)\", ylabel=\"10y\", yscale=10, xshift=-10, xscale=0.1\n", ")\n", "sp.add_line([0, 1, 2, 3], [0, 1, 4, 9], label=\"Line 1\", linestyle=\"-.\")\n", "sp.add_line([0, 1, 2, 3], [0, 2, 3, 4], linestyle=\"dashed\", color=\"red\", label=\"Line 2\")\n", "c.show()" ] } ], "metadata": { "kernelspec": { "display_name": "env_maxplotlib", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }