{ "cells": [ { "cell_type": "markdown", "id": "plot-title", "metadata": {}, "source": [ "# Plotting\n", "\n", "MATLAB plotting commands render through numbl's figure renderer, straight\n", "into the cell output — no display server involved. 3-D figures are\n", "interactive (drag to rotate).\n", "\n", "Figures are per-cell, like inline matplotlib: each cell renders the figures\n", "its own commands produce." ] }, { "cell_type": "code", "execution_count": null, "id": "plot-lines", "metadata": {}, "outputs": [], "source": [ "x = linspace(0, 2*pi, 200);\n", "plot(x, sin(x), 'b-');\n", "hold on;\n", "plot(x, cos(x), 'r--');\n", "hold off;\n", "title('sin and cos');\n", "xlabel('x');\n", "legend('sin', 'cos');" ] }, { "cell_type": "code", "execution_count": null, "id": "plot-subplot", "metadata": {}, "outputs": [], "source": [ "subplot(1, 2, 1); plot(x, sin(x)); title('sin(x)');\n", "subplot(1, 2, 2); plot(x, sin(2*x)); title('sin(2x)');" ] }, { "cell_type": "code", "execution_count": null, "id": "plot-imagesc", "metadata": {}, "outputs": [], "source": [ "Z = peaks(80);\n", "imagesc(Z);\n", "colorbar;\n", "title('peaks');" ] }, { "cell_type": "code", "execution_count": null, "id": "plot-surf", "metadata": {}, "outputs": [], "source": [ "surf(peaks(40));\n", "title('peaks surface — drag to rotate');" ] } ], "metadata": { "kernelspec": { "display_name": "MATLAB (numbl)", "language": "matlab", "name": "numbl" }, "language_info": { "codemirror_mode": "octave", "file_extension": ".m", "mimetype": "text/x-octave", "name": "matlab", "pygments_lexer": "matlab" } }, "nbformat": 4, "nbformat_minor": 5 }