{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "The examples in this notebook were taken from the Maxima documentation.\n", "\n", "# Standard Plots\n", "\n", "First set the default plot options to SVG output so that Maxima-Jupyter can capture the output." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "set_plot_option([svg_file, \"maxplot.svg\"]);\n", "set_plot_option([plot_format,gnuplot]);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `contour_plot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot2d ([contour, y^2+x^2], [x,-4,4], [y,-4,4]);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `julia` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "julia (-0.55, 0.6, [iterations, 36], [x, -0.3, 0.2],\n", " [y, 0.3, 0.9], [grid, 400, 400], [color_bar_tics, 0, 6, 36])$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `mandelbrot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mandelbrot ([iterations, 30], [x, -2, 1], [y, -1.2, 1.2],\n", " [grid,400,400]);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `plot2d` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot2d (sin(x), [x, -%pi, %pi])$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `plot3d` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100],\n", " [mesh_lines_color,false])$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# `draw` Plots\n", "First load the `draw` package and set the default terminal to `svg`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "load(\"draw\")$\n", "set_draw_defaults(file_name=\"maxplot.svg\",terminal='svg)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `draw2d` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "draw2d(explicit(((1+x)**2/(1+x*x))-1,x,-10,10))$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `draw3d` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "draw3d(\n", " colorbox = \"Magnitude\",\n", " enhanced3d = true,\n", " explicit(x^2+y^2,x,-1,1,y,-1,1))$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `draw` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "draw(\n", " gr2d(\n", " key=\"sin (x)\",grid=[2,2],\n", " explicit(\n", " sin(x),\n", " x,0,2*%pi\n", " )\n", " ),\n", " gr2d(\n", " key=\"cos (x)\",grid=[2,2],\n", " explicit(\n", " cos(x),\n", " x,0,2*%pi\n", " )\n", " )\n", " )$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `animated_gif` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "set_draw_defaults(terminal=animated_gif)$\n", "sp(ang):=gr3d(enhanced3d = true,\n", " color = green,\n", " logcb = true,\n", " logz = true,\n", " palette = [-15,24,-9],\n", " view=[60,ang],\n", " explicit(exp(x^2-y^2), x,-2,2,y,-2,2))$\n", "draw(delay=50,\n", " terminal = animated_gif,\n", " makelist(sp(mod(i, 360)),i,5,365,30))$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# `descriptive` Plots\n", "First load `descriptive` and `distrib`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "load (\"descriptive\")$\n", "load (\"distrib\")$\n", "set_draw_defaults(terminal=svg)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `barsplot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "l1:makelist(random(10),k,1,50)$\n", "l2:makelist(random(10),k,1,100)$\n", "barsplot(\n", " l1,l2,\n", " box_width = 1,\n", " fill_density = 1,\n", " bars_colors = [black, grey],\n", " frequency = relative,\n", " sample_keys = [\"A\", \"B\"])$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `boxplot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s2 : read_matrix(file_search(\"wind.data\"))$\n", "boxplot(s2,\n", " box_width = 0.2,\n", " title = \"Windspeed in knots\",\n", " xlabel = \"Stations\",\n", " color = red,\n", " line_width = 2)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `histogram` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s1 : read_list (file_search (\"pidigits.data\"))$\n", "histogram (\n", " s1,\n", " nclasses = 8,\n", " title = \"pi digits\",\n", " xlabel = \"digits\",\n", " ylabel = \"Absolute frequency\",\n", " fill_color = grey,\n", " fill_density = 0.6)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `piechart` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "piechart(\n", " s1,\n", " xrange = [-1.1, 1.3],\n", " yrange = [-1.1, 1.1],\n", " title = \"Digit frequencies in pi\")$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `scatterplot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "s2 : read_matrix (file_search (\"wind.data\"))$\n", "scatterplot(\n", " submatrix(s2, 1,2,3),\n", " title = \"Data from stations #4 and #5\",\n", " point_type = diamant,\n", " point_size = 2,\n", " color = blue)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `starplot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "starplot(\n", " l1, l2,\n", " stars_colors = [blue,red],\n", " sample_keys = [\"1st sample\", \"2nd sample\"],\n", " star_center = [1,2],\n", " star_radius = 4,\n", " proportional_axes = xy,\n", " line_width = 2 ) $ " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `stemplot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stemplot(\n", " random_normal(15, 6, 100),\n", " leaf_unit = 0.1)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## `implicit_plot` Example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "load(implicit_plot)$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "implicit_plot (x^2 = y^3 - 3*y + 1, [x, -4, 4], [y, -4, 4])$" ] } ], "metadata": { "kernelspec": { "display_name": "Maxima", "language": "maxima", "name": "maxima" }, "language_info": { "codemirror_mode": "maxima", "file_extension": ".mac", "mimetype": "text/x-maxima", "name": "maxima", "pygments_lexer": "maxima", "version": "5.47.0" } }, "nbformat": 4, "nbformat_minor": 4 }