From 4f853ff71cf1e6410b752c6190f3b9ded7b4eac5 Mon Sep 17 00:00:00 2001 From: yankev Date: Mon, 15 Feb 2016 10:54:20 -0500 Subject: [PATCH 1/8] test commit --- contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing.md b/contributing.md index 537e46e7b55..67ea38de0cb 100644 --- a/contributing.md +++ b/contributing.md @@ -98,7 +98,7 @@ To install the optional dependencies: pip install -r optional-requirements.txt ``` -##Testing +##Testing Our API uses Nose to run tests. (https://nose.readthedocs.org/en/latest/) From ecfe1fbfdfb7c4869caaa959fcaa9a8ad52edbec Mon Sep 17 00:00:00 2001 From: yankev Date: Mon, 15 Feb 2016 15:50:52 -0500 Subject: [PATCH 2/8] issue #399 fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can now enter in a dictionary for all the options you want using the parameter ‘config’. --- plotly/offline/offline.py | 30 ++++++++++--- temp-plot.html | 92 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 temp-plot.html diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index f2153b94e80..703a6caaab7 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -71,7 +71,7 @@ def init_notebook_mode(): '')) -def _plot_html(figure_or_data, show_link, link_text, +def _plot_html(figure_or_data, config, validate, default_width, default_height): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -97,10 +97,30 @@ def _plot_html(figure_or_data, show_link, link_text, jdata = json.dumps(figure.get('data', []), cls=utils.PlotlyJSONEncoder) jlayout = json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) - config = {} - config['showLink'] = show_link - config['linkText'] = link_text - jconfig = json.dumps(config) + configkeys = ( + 'editable', + 'autosizable', + 'fillFrame', + 'frameMargins', + 'scrollZoom', + 'doubleClick', + 'showTips', + 'showLink', + 'sendData', + 'linkText', + 'showSources', + 'displayModeBar', + 'modeBarButtonsToRemove', + 'modeBarButtonsToAdd', + 'modeBarButtons', + 'displaylogo', + 'plotGlPixelRatio', + 'setBackground', + 'topojsonURL') + + config_clean = dict((k,config[k]) for k in configkeys if k in config) + + jconfig = json.dumps(config_clean) # TODO: The get_config 'source of truth' should # really be somewhere other than plotly.plotly diff --git a/temp-plot.html b/temp-plot.html new file mode 100644 index 00000000000..6bcb16e90d7 --- /dev/null +++ b/temp-plot.html @@ -0,0 +1,92 @@ +
\ No newline at end of file From fa433c301c09e385d32bc2d8b603475e601241ec Mon Sep 17 00:00:00 2001 From: yankev Date: Mon, 15 Feb 2016 16:05:20 -0500 Subject: [PATCH 3/8] update schema --- plotly/graph_reference/default-schema.json | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plotly/graph_reference/default-schema.json b/plotly/graph_reference/default-schema.json index adff88bc8f5..6218fde4659 100644 --- a/plotly/graph_reference/default-schema.json +++ b/plotly/graph_reference/default-schema.json @@ -4405,7 +4405,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -5594,7 +5594,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -6134,7 +6134,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -6781,7 +6781,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -7660,7 +7660,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -8307,7 +8307,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -8933,7 +8933,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -9617,7 +9617,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, @@ -10933,7 +10933,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -12308,7 +12308,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -13197,7 +13197,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -14428,7 +14428,7 @@ } }, "colorscale": { - "description": "Has only an effect if `marker.color` is set to a numerical array. Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use cmin and cmax", "role": "style", "valType": "colorscale" }, @@ -15053,7 +15053,7 @@ } }, "colorscale": { - "description": "Sets the colorscale.", + "description": "Sets the colorscale. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in z space, use zmin and zmax", "role": "style", "valType": "colorscale" }, From efc8ae71795a5f930894a1767a765e120b90d558 Mon Sep 17 00:00:00 2001 From: yankev Date: Mon, 15 Feb 2016 17:04:08 -0500 Subject: [PATCH 4/8] added original parameters in addition to config --- plotly/offline/offline.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 703a6caaab7..3f962e9b3a4 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -71,8 +71,8 @@ def init_notebook_mode(): '')) -def _plot_html(figure_or_data, config, - validate, default_width, default_height): +def _plot_html(figure_or_data, show_link, link_text, + validate, default_width, default_height, config): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) From 75ec3e1d8058c24bb28924da9a3eae5254a26f69 Mon Sep 17 00:00:00 2001 From: yankev Date: Mon, 15 Feb 2016 18:43:28 -0500 Subject: [PATCH 5/8] replaced parameters replaces all show_link,link_text with config --- plotly/offline/offline.py | 23 +++++++++++------------ temp-plot.html | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 3f962e9b3a4..2c811dde581 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -71,8 +71,8 @@ def init_notebook_mode(): '')) -def _plot_html(figure_or_data, show_link, link_text, - validate, default_width, default_height, config): +def _plot_html(figure_or_data, config, + validate, default_width, default_height): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -157,7 +157,7 @@ def _plot_html(figure_or_data, show_link, link_text, return plotly_html_div, plotdivid, width, height -def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', +def iplot(figure_or_data, config = {'show_link': True, 'link_text': 'Export to plot.ly'}, validate=True): """ Draw plotly graphs inside an IPython notebook without @@ -205,14 +205,13 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', from IPython.display import HTML, display plot_html, plotdivid, width, height = _plot_html( - figure_or_data, show_link, link_text, validate, + figure_or_data, config, validate, '100%', 525) display(HTML(plot_html)) -def plot(figure_or_data, - show_link=True, link_text='Export to plot.ly', +def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot.ly'}, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', @@ -274,7 +273,7 @@ def plot(figure_or_data, filename += '.html' plot_html, plotdivid, width, height = _plot_html( - figure_or_data, show_link, link_text, validate, + figure_or_data, config, validate, '100%', '100%') figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -332,7 +331,7 @@ def plot(figure_or_data, def plot_mpl(mpl_fig, resize=False, strip_style=False, - verbose=False, show_link=True, link_text='Export to plot.ly', + verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'}, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', auto_open=True): """ @@ -395,13 +394,13 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False, ``` """ plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose) - return plot(plotly_plot, show_link, link_text, validate, output_type, + return plot(plotly_plot, config, validate, output_type, include_plotlyjs, filename, auto_open) def iplot_mpl(mpl_fig, resize=False, strip_style=False, - verbose=False, show_link=True, - link_text='Export to plot.ly', validate=True): + verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'}, + validate=True): """ Convert a matplotlib figure to a plotly graph and plot inside an IPython notebook without connecting to an external server. @@ -450,7 +449,7 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False, ``` """ plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose) - return iplot(plotly_plot, show_link, link_text, validate) + return iplot(plotly_plot, config, validate) def enable_mpl_offline(resize=False, strip_style=False, diff --git a/temp-plot.html b/temp-plot.html index 6bcb16e90d7..e3dc78847f5 100644 --- a/temp-plot.html +++ b/temp-plot.html @@ -89,4 +89,4 @@ },{"sane-topojson":15}]},{},[16])(16) });PlotlyGeoAssets.version='1.0.0'; -
\ No newline at end of file +
\ No newline at end of file From 108109abeba2a7c8f12e1a2c15a7887fb1254e07 Mon Sep 17 00:00:00 2001 From: yankev Date: Tue, 16 Feb 2016 13:12:13 -0500 Subject: [PATCH 6/8] updated fix changed required parameters of all functions and updated the descriptions. --- plotly/offline/offline.py | 63 ++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 2c811dde581..247f0463da7 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -126,13 +126,15 @@ def _plot_html(figure_or_data, config, # really be somewhere other than plotly.plotly plotly_platform_url = plotly.plotly.get_config().get('plotly_domain', 'https://plot.ly') + if (plotly_platform_url != 'https://plot.ly' and - link_text == 'Export to plot.ly'): + 'linkText' in config): link_domain = plotly_platform_url\ .replace('https://', '')\ .replace('http://', '') - link_text = link_text.replace('plot.ly', link_domain) + + config['linkText'] = config['linkText'].replace('plot.ly', link_domain) script = 'Plotly.newPlot("{id}", {data}, {layout}, {config})'.format( id=plotdivid, @@ -157,7 +159,7 @@ def _plot_html(figure_or_data, config, return plotly_html_div, plotdivid, width, height -def iplot(figure_or_data, config = {'show_link': True, 'link_text': 'Export to plot.ly'}, +def iplot(figure_or_data, config = {'showLink': True, 'linkText': 'Export to plot.ly'}, validate=True): """ Draw plotly graphs inside an IPython notebook without @@ -172,10 +174,12 @@ def iplot(figure_or_data, config = {'show_link': True, 'link_text': 'Export to p graph descriptions. Keyword arguments: - show_link (default=True) -- display a link in the bottom-right corner of - of the chart that will export the chart to - Plotly Cloud or Plotly Enterprise - link_text (default='Export to plot.ly') -- the text of export link + config -- a dictionary with configuration attributes for the plot, + default contains the following two elements: + showLink (default=True) -- display a link in the bottom-right corner of + of the chart that will export the chart to + Plotly Cloud or Plotly Enterprise + linkText (default='Export to plot.ly') -- the text of export link validate (default=True) -- validate that all of the keys in the figure are valid? omit if your version of plotly.js has become outdated with your version of @@ -211,7 +215,7 @@ def iplot(figure_or_data, config = {'show_link': True, 'link_text': 'Export to p display(HTML(plot_html)) -def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot.ly'}, +def plot(figure_or_data, config = {'showLink':True, 'linkText':'Export to plot.ly'}, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', @@ -233,10 +237,12 @@ def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot graph descriptions. Keyword arguments: - show_link (default=True) -- display a link in the bottom-right corner of - of the chart that will export the chart to Plotly Cloud or - Plotly Enterprise - link_text (default='Export to plot.ly') -- the text of export link + config -- a dictionary with configuration attributes for the plot, + default contains the following two elements: + showLink (default=True) -- display a link in the bottom-right corner of + of the chart that will export the chart to Plotly Cloud or + Plotly Enterprise + linkText (default='Export to plot.ly') -- the text of export link validate (default=True) -- validate that all of the keys in the figure are valid? omit if your version of plotly.js has become outdated with your version of graph_reference.json or if you need to include @@ -331,7 +337,7 @@ def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot def plot_mpl(mpl_fig, resize=False, strip_style=False, - verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'}, + verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'}, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', auto_open=True): """ @@ -349,10 +355,12 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False, resize (default=False) -- allow plotly to choose the figure size. strip_style (default=False) -- allow plotly to choose style options. verbose (default=False) -- print message. - show_link (default=True) -- display a link in the bottom-right corner of - of the chart that will export the chart to Plotly Cloud or - Plotly Enterprise - link_text (default='Export to plot.ly') -- the text of export link + config -- a dictionary with configuration attributes for the plot, + default contains the following two elements: + showLink (default=True) -- display a link in the bottom-right corner of + of the chart that will export the chart to Plotly Cloud or + Plotly Enterprise + linkText (default='Export to plot.ly') -- the text of export link validate (default=True) -- validate that all of the keys in the figure are valid? omit if your version of plotly.js has become outdated with your version of graph_reference.json or if you need to include @@ -399,7 +407,7 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False, def iplot_mpl(mpl_fig, resize=False, strip_style=False, - verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'}, + verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'}, validate=True): """ Convert a matplotlib figure to a plotly graph and plot inside an IPython @@ -420,13 +428,12 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False, resize (default=False) -- allow plotly to choose the figure size. strip_style (default=False) -- allow plotly to choose style options. verbose (default=False) -- print message. - show_link (default=True) -- display a link in the bottom-right corner of - of the chart that will export the chart to Plotly Cloud or - Plotly Enterprise - show_link (default=True) -- display a link in the bottom-right corner of - of the chart that will export the chart to - Plotly Cloud or Plotly Enterprise - link_text (default='Export to plot.ly') -- the text of export link + config -- a dictionary with configuration attributes for the plot, + default contains the following two elements: + showLink (default=True) -- display a link in the bottom-right corner of + of the chart that will export the chart to + Plotly Cloud or Plotly Enterprise + linkText (default='Export to plot.ly') -- the text of export link validate (default=True) -- validate that all of the keys in the figure are valid? omit if your version of plotly.js has become outdated with your version of @@ -453,8 +460,8 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False, def enable_mpl_offline(resize=False, strip_style=False, - verbose=False, show_link=True, - link_text='Export to plot.ly', validate=True): + verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'}, + validate=True): """ Convert mpl plots to locally hosted HTML documents. @@ -487,5 +494,5 @@ def enable_mpl_offline(resize=False, strip_style=False, formatter = ip.display_formatter.formatters['text/html'] formatter.for_type(matplotlib.figure.Figure, lambda fig: iplot_mpl(fig, resize, strip_style, verbose, - show_link, link_text, validate)) + config, validate)) From 687e2333f32d2fd5f18999577793b53b77ca012f Mon Sep 17 00:00:00 2001 From: yankev Date: Tue, 16 Feb 2016 14:07:53 -0500 Subject: [PATCH 7/8] pep8 changes --- plotly/offline/offline.py | 51 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 247f0463da7..124f4b49f73 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -9,9 +9,11 @@ import os import uuid import warnings -from pkg_resources import resource_string import webbrowser +from pkg_resources import resource_string + + import plotly from plotly import tools, utils from plotly.exceptions import PlotlyError @@ -98,25 +100,25 @@ def _plot_html(figure_or_data, config, jlayout = json.dumps(figure.get('layout', {}), cls=utils.PlotlyJSONEncoder) configkeys = ( - 'editable', - 'autosizable', - 'fillFrame', - 'frameMargins', - 'scrollZoom', - 'doubleClick', - 'showTips', - 'showLink', - 'sendData', - 'linkText', - 'showSources', - 'displayModeBar', - 'modeBarButtonsToRemove', - 'modeBarButtonsToAdd', - 'modeBarButtons', - 'displaylogo', - 'plotGlPixelRatio', - 'setBackground', - 'topojsonURL') + 'editable', + 'autosizable', + 'fillFrame', + 'frameMargins', + 'scrollZoom', + 'doubleClick', + 'showTips', + 'showLink', + 'sendData', + 'linkText', + 'showSources', + 'displayModeBar', + 'modeBarButtonsToRemove', + 'modeBarButtonsToAdd', + 'modeBarButtons', + 'displaylogo', + 'plotGlPixelRatio', + 'setBackground', + 'topojsonURL') config_clean = dict((k,config[k]) for k in configkeys if k in config) @@ -159,7 +161,7 @@ def _plot_html(figure_or_data, config, return plotly_html_div, plotdivid, width, height -def iplot(figure_or_data, config = {'showLink': True, 'linkText': 'Export to plot.ly'}, +def iplot(figure_or_data, config={'showLink': True, 'linkText': 'Export to plot.ly'}, validate=True): """ Draw plotly graphs inside an IPython notebook without @@ -406,8 +408,8 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False, include_plotlyjs, filename, auto_open) -def iplot_mpl(mpl_fig, resize=False, strip_style=False, - verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'}, +def iplot_mpl(mpl_fig, resize=False, strip_style=False, verbose=False, + config={'showLink': True, 'linkText': 'Export to plot.ly'}, validate=True): """ Convert a matplotlib figure to a plotly graph and plot inside an IPython @@ -494,5 +496,4 @@ def enable_mpl_offline(resize=False, strip_style=False, formatter = ip.display_formatter.formatters['text/html'] formatter.for_type(matplotlib.figure.Figure, lambda fig: iplot_mpl(fig, resize, strip_style, verbose, - config, validate)) - + config, validate)) \ No newline at end of file From 2f8cbc8c2f0ed992ad3cb2368a538a4e7b45f01f Mon Sep 17 00:00:00 2001 From: yankev Date: Tue, 16 Feb 2016 15:49:51 -0500 Subject: [PATCH 8/8] pep8 updates --- plotly/offline/offline.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index 124f4b49f73..7ed8689eb46 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -161,7 +161,8 @@ def _plot_html(figure_or_data, config, return plotly_html_div, plotdivid, width, height -def iplot(figure_or_data, config={'showLink': True, 'linkText': 'Export to plot.ly'}, +def iplot(figure_or_data, + config={'showLink': True, 'linkText': 'Export to plot.ly'}, validate=True): """ Draw plotly graphs inside an IPython notebook without @@ -217,7 +218,8 @@ def iplot(figure_or_data, config={'showLink': True, 'linkText': 'Export to plot. display(HTML(plot_html)) -def plot(figure_or_data, config = {'showLink':True, 'linkText':'Export to plot.ly'}, +def plot(figure_or_data, + config={'showLink': True, 'linkText': 'Export to plot.ly'}, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', @@ -338,8 +340,8 @@ def plot(figure_or_data, config = {'showLink':True, 'linkText':'Export to plot.l return plot_html -def plot_mpl(mpl_fig, resize=False, strip_style=False, - verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'}, +def plot_mpl(mpl_fig, resize=False, strip_style=False, verbose=False, + config={'showLink': True, 'linkText': 'Export to plot.ly'}, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', auto_open=True): """ @@ -461,9 +463,10 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False, verbose=False, return iplot(plotly_plot, config, validate) -def enable_mpl_offline(resize=False, strip_style=False, - verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'}, - validate=True): +def enable_mpl_offline(resize=False, strip_style=False, verbose=False, + config={'showLink': True, + 'linkText': 'Export to plot.ly'}, + validate=True): """ Convert mpl plots to locally hosted HTML documents. @@ -496,4 +499,4 @@ def enable_mpl_offline(resize=False, strip_style=False, formatter = ip.display_formatter.formatters['text/html'] formatter.for_type(matplotlib.figure.Figure, lambda fig: iplot_mpl(fig, resize, strip_style, verbose, - config, validate)) \ No newline at end of file + config, validate))