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