{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EzPlot Example \n", "\n", "To [download this Jupyter Notebook](EzPlot_Example.ipynb), right click on the link and choose \"Download Linked File As...\" or \"Save Link as...\". Remember where you saved the downloaded file, which should have an .ipynb extension. (You'll need to launch the Jupyter notebook or JupyterLab instance from the location where you store the notebook file.)" ] }, { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Simple Plot\n", "\n", "[Back to Top](#top)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import vcs\n", "import cdms2\n", "import vcsaddons.EzPlot\n", "import cdutil\n", "import math\n", "import random\n", "\n", "# Simple Plot with EzPlot\n", "\n", "\n", "variables = []\n", "line_type = []\n", "line_widths = []\n", "legend_texts = []\n", "legend_text_colors = []\n", "marker_type = []\n", "\n", "for v in range(0, 20):\n", " var = []\n", " for i in range(0, 100):\n", " if v%2 == 0:\n", " #var.append(random.random() * v * math.sin(2*math.pi*float(i-v)/100.0))\n", " var.append(v * math.sin(2*math.pi*float(i-v)/100.0))\n", " else:\n", " #var.append(random.random() * v * math.cos(2*math.pi*float(i-v)/100.0))\n", " var.append(v * math.cos(2*math.pi*float(i-v)/100.0))\n", " line_type += [\"solid\"]\n", " line_widths += [5]\n", " if i%2 == 0:\n", " legend_texts += [\"Sin\"]\n", " else: \n", " legend_texts += [\"Cos\"]\n", " legend_text_colors += ['black']\n", " marker_type += [None]\n", " variables.append(var)\n", "\n", "plotfunction = vcsaddons.EzPlot.EzLinePlot()\n", "\n", "canvas = vcs.init()\n", "\n", "d = plotfunction.lineplot(data=variables, canvas=canvas, title=\"Simple 2 EzLinePlot\", titlesize=30,\n", " #backgroundcolor=[0, 100, 0],\n", " linetypes=line_type, linewidths=line_widths,\n", " legendposition=[0.25, 0.35, 0.30, 0.40], legendtextcolors=legend_text_colors, \n", " legendtexts=legend_texts,\n", " legendbackgroundcolor=\"yellow\",\n", " enablegrid=True)\n", "\n", "canvas.png(\"EzPlot_Simple2\")\n", "\n", "d" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The CDAT software was developed by LLNL. This tutorial was written by Charles Doutriaux. This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.\n", "\n", "If you have questions about this notebook, please email our [CDAT Support](cdat-support@llnl.gov) address, cdat-support@llnl.gov." ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:cdat81-mesa] *", "language": "python", "name": "conda-env-cdat81-mesa-py" }, "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.6.7" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }