{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotters Tutorial with Jupyter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is a interactive tutorial for [`Plotters`](https://github.com/38/plotters) drawing library. If you are looking at the static HTML version and want to try the interactive version. Please follow the steps:\n", "\n", "#### For Ubuntu/Debian users\n", "\n", "```bash\n", "# Install Jupyter notebook \n", "sudo apt install libzmq3-dev jupyter-notebook\n", "cargo install evcxr_jupyter\n", "evcxr_jupyter --install\n", "# Get the notebook\n", "git clone https://github.com/38/plotters-doc-data\n", "cd plotteres-doc-data\n", "jupyter notebook\n", "```\n", "\n", "#### For OSX users\n", "\n", "```bash\n", "# Install Jupyter notebook \n", "brew install zeromq pkg-config\n", "cargo install evcxr_jupyter\n", "evcxr_jupyter --install\n", "# Get the notebook\n", "git clone https://github.com/38/plotters-doc-data\n", "cd plotteres-doc-data\n", "jupyter notebook\n", "```\n", "\n", "You can also download the latest notebook from [https://raw.githubusercontent.com/38/plotters-doc-data/master/evcxr-jupyter-integration.ipynb](https://raw.githubusercontent.com/38/plotters-doc-data/master/evcxr-jupyter-integration.ipynb), thus you don't have to clone the entire data repo." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get Started" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In order to use `Plotters` in `jupyter-evcxr`, you need both Jupyter and evcxr installed.\n", "Check [https://github.com/google/evcxr](https://github.com/google/evcxr) for the instructions.\n", "\n", "To use Plotters with `jupyter-evcxr`, you need to import it using the following code:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ ":dep plotters = { version = \"^0.3.0\", default_features = false, features = [\"evcxr\", \"all_series\"] }" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because `evcxr` uses only SVG images and all types of series, so we don't need other types of backend. So we should put\n", "\n", "`default_features = false, features = [\"evcxr\", \"all_series\"]`\n", "\n", "Make the compilation faster. Since `evcxr` shares all the artifacts among cells, after the first time we have `plotters` compiled, it should be faster after." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plotters evcxr integration overview" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To use plotters, the most convenient way is importing everything defined in the `prelude` module.\n", "It will import `evcxr_figure` function for `evcxr` integration. \n", "\n", "*Note: Currently evcxr doesn't work with nightly rust, so please make sure you are using a stable rust*" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "