/ concept-collection / jupyterlite-numbl-kernel
Sign in
concept-collection / jupyterlite-numbl-kernel
jupyterlite-numbl-kernel / demo / content / 02-plotting.ipynb
87 lines · 2.1 KBBlameHistoryRaw
1{
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "id": "plot-title",
6 "metadata": {},
7 "source": [
8 "# Plotting\n",
9 "\n",
10 "MATLAB plotting commands render through numbl's figure renderer, straight\n",
11 "into the cell output — no display server involved. 3-D figures are\n",
12 "interactive (drag to rotate).\n",
13 "\n",
14 "Figures are per-cell, like inline matplotlib: each cell renders the figures\n",
15 "its own commands produce."
16 ]
17 },
18 {
19 "cell_type": "code",
20 "execution_count": null,
21 "id": "plot-lines",
22 "metadata": {},
23 "outputs": [],
24 "source": [
25 "x = linspace(0, 2*pi, 200);\n",
26 "plot(x, sin(x), 'b-');\n",
27 "hold on;\n",
28 "plot(x, cos(x), 'r--');\n",
29 "hold off;\n",
30 "title('sin and cos');\n",
31 "xlabel('x');\n",
32 "legend('sin', 'cos');"
33 ]
34 },
35 {
36 "cell_type": "code",
37 "execution_count": null,
38 "id": "plot-subplot",
39 "metadata": {},
40 "outputs": [],
41 "source": [
42 "subplot(1, 2, 1); plot(x, sin(x)); title('sin(x)');\n",
43 "subplot(1, 2, 2); plot(x, sin(2*x)); title('sin(2x)');"
44 ]
45 },
46 {
47 "cell_type": "code",
48 "execution_count": null,
49 "id": "plot-imagesc",
50 "metadata": {},
51 "outputs": [],
52 "source": [
53 "Z = peaks(80);\n",
54 "imagesc(Z);\n",
55 "colorbar;\n",
56 "title('peaks');"
57 ]
58 },
59 {
60 "cell_type": "code",
61 "execution_count": null,
62 "id": "plot-surf",
63 "metadata": {},
64 "outputs": [],
65 "source": [
66 "surf(peaks(40));\n",
67 "title('peaks surface — drag to rotate');"
68 ]
69 }
70 ],
71 "metadata": {
72 "kernelspec": {
73 "display_name": "MATLAB (numbl)",
74 "language": "matlab",
75 "name": "numbl"
76 },
77 "language_info": {
78 "codemirror_mode": "octave",
79 "file_extension": ".m",
80 "mimetype": "text/x-octave",
81 "name": "matlab",
82 "pygments_lexer": "matlab"
83 }
84 },
85 "nbformat": 4,
86 "nbformat_minor": 5
moveopenescclose