[Python-modules-commits] [python-mplexporter] 21/135: Functional IPython notebook in notebooks directory.
Wolfgang Borgert
debacle at moszumanska.debian.org
Tue Sep 23 21:18:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to branch master
in repository python-mplexporter.
commit 302112a87db10c436bf8974605c7e1fccef7f2d4
Author: theengineear <andseier at gmail.com>
Date: Wed Feb 19 18:19:04 2014 -0800
Functional IPython notebook in notebooks directory.
IPython notebook runs, but plotly plot is not embedded in notebook yet.
---
mplexporter/renderers/__init__.py | 2 +-
notebooks/PlotlyTest.ipynb | 70 ++++++++++++++++++++++++++++++++++++---
2 files changed, 67 insertions(+), 5 deletions(-)
diff --git a/mplexporter/renderers/__init__.py b/mplexporter/renderers/__init__.py
index 73792c2..cd481fc 100644
--- a/mplexporter/renderers/__init__.py
+++ b/mplexporter/renderers/__init__.py
@@ -2,4 +2,4 @@ from .base import Renderer
from .vega_renderer import VegaRenderer, fig_to_vega
from .vincent_renderer import VincentRenderer, fig_to_vincent
from .example_renderer import ExampleRenderer
-from .plotly import PlotlyRenderer
+from .plotly import PlotlyRenderer, fig_to_plotly
diff --git a/notebooks/PlotlyTest.ipynb b/notebooks/PlotlyTest.ipynb
index c6b6800..21f215f 100644
--- a/notebooks/PlotlyTest.ipynb
+++ b/notebooks/PlotlyTest.ipynb
@@ -8,28 +8,90 @@
{
"cells": [
{
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Re-Creating matplotlib Plots in Plotly"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 5,
+ "metadata": {},
+ "source": [
+ "Many users are familiar with creating plots from the matplotlib package, the mplexporter package gives users access to an Exporter class that will crawl figure structures created from matplotlib. This exporter can be used in conjunction with one of many renderers to pass the properties and data along to another program. The following is an example using the PlotlyRenderer."
+ ]
+ },
+ {
"cell_type": "code",
"collapsed": false,
"input": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
- "# from mplexporter.renderers import fig_to_vega"
+ "from mplexporter.renderers import fig_to_plotly"
],
"language": "python",
"metadata": {},
- "outputs": []
+ "outputs": [],
+ "prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# from mplexporter.tools import ipynb_vega_init\n",
- "# ipynb_vega_init()"
+ "# ipynb_vega_init()\n",
+ "# from mplexporter.tools import ipynb_plotly_init\n",
+ "username = 'IPython.Demo'\n",
+ "api_key = '1fw3zw2o13'"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# setup matplotlib plot\n",
+ "x = np.arange(0,1.0,0.01)\n",
+ "y1 = np.sin(2*np.pi*x)\n",
+ "y2 = np.cos(4*np.pi*x)\n",
+ "plt.plot(x, y1, 'b--', label='sin')\n",
+ "plt.plot(x, y2, 'ro', label='cos')\n",
+ "plt.title(\"It's a Sign\")\n",
+ "plt.xlabel('time')\n",
+ "plt.ylabel('amplitude')\n",
+ "plt.legend().set_visible(True)\n",
+ "fig = plt.gcf()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "metadata": {},
+ "output_type": "display_data",
+ "png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAEZCAYAAABrUHmEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlcVdX6P/DPYXJERFRiSvTgVRRFzFT0a2CFKCrZpPj1\namZ5rcyhur+rgYbD1TSrbw5lZo5lZnkdGcwsQUsRpyuOqCQKqDihOCOc9ftjCzKcI4dz9rD23s/7\n9Tov4Zx99n72Wou93Huv9WwDY4yBEEIIsYKD0gEQQghRD+o0CCGEWI06DUIIIVajToMQQojVqNMg\nhBBiNeo0CCGEWI06DUI4snPnTrRu3VrpMAixiDoNoiv+/v74/fffAQDLly9Hjx49Knw+fPhwrFix\nQtIYjh49il69esHDwwPu7u7o1KkTkpOTAQA9evTAiRMnJN0+IfZwUjoAQuRkMBjs+lwM/fv3x+jR\no5GUlATGG [...]
+ "text": [
+ "<matplotlib.figure.Figure at 0x106ff2dd0>"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "fig_to_plotly(fig, username, api_key)"
],
"language": "python",
"metadata": {},
- "outputs": []
+ "outputs": [],
+ "prompt_number": 9
}
],
"metadata": {}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git
More information about the Python-modules-commits
mailing list