Skip to content

Commit 75ec3e1

Browse files
author
yankev
committed
replaced parameters
replaces all show_link,link_text with config
1 parent efc8ae7 commit 75ec3e1

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

plotly/offline/offline.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def init_notebook_mode():
7171
'</script>'))
7272

7373

74-
def _plot_html(figure_or_data, show_link, link_text,
75-
validate, default_width, default_height, config):
74+
def _plot_html(figure_or_data, config,
75+
validate, default_width, default_height):
7676

7777
figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)
7878

@@ -157,7 +157,7 @@ def _plot_html(figure_or_data, show_link, link_text,
157157
return plotly_html_div, plotdivid, width, height
158158

159159

160-
def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
160+
def iplot(figure_or_data, config = {'show_link': True, 'link_text': 'Export to plot.ly'},
161161
validate=True):
162162
"""
163163
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',
205205
from IPython.display import HTML, display
206206

207207
plot_html, plotdivid, width, height = _plot_html(
208-
figure_or_data, show_link, link_text, validate,
208+
figure_or_data, config, validate,
209209
'100%', 525)
210210

211211
display(HTML(plot_html))
212212

213213

214-
def plot(figure_or_data,
215-
show_link=True, link_text='Export to plot.ly',
214+
def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot.ly'},
216215
validate=True, output_type='file',
217216
include_plotlyjs=True,
218217
filename='temp-plot.html',
@@ -274,7 +273,7 @@ def plot(figure_or_data,
274273
filename += '.html'
275274

276275
plot_html, plotdivid, width, height = _plot_html(
277-
figure_or_data, show_link, link_text, validate,
276+
figure_or_data, config, validate,
278277
'100%', '100%')
279278

280279
figure = tools.return_figure_from_figure_or_data(figure_or_data, validate)
@@ -332,7 +331,7 @@ def plot(figure_or_data,
332331

333332

334333
def plot_mpl(mpl_fig, resize=False, strip_style=False,
335-
verbose=False, show_link=True, link_text='Export to plot.ly',
334+
verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'},
336335
validate=True, output_type='file', include_plotlyjs=True,
337336
filename='temp-plot.html', auto_open=True):
338337
"""
@@ -395,13 +394,13 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
395394
```
396395
"""
397396
plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose)
398-
return plot(plotly_plot, show_link, link_text, validate, output_type,
397+
return plot(plotly_plot, config, validate, output_type,
399398
include_plotlyjs, filename, auto_open)
400399

401400

402401
def iplot_mpl(mpl_fig, resize=False, strip_style=False,
403-
verbose=False, show_link=True,
404-
link_text='Export to plot.ly', validate=True):
402+
verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'},
403+
validate=True):
405404
"""
406405
Convert a matplotlib figure to a plotly graph and plot inside an IPython
407406
notebook without connecting to an external server.
@@ -450,7 +449,7 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False,
450449
```
451450
"""
452451
plotly_plot = tools.mpl_to_plotly(mpl_fig, resize, strip_style, verbose)
453-
return iplot(plotly_plot, show_link, link_text, validate)
452+
return iplot(plotly_plot, config, validate)
454453

455454

456455
def enable_mpl_offline(resize=False, strip_style=False,

temp-plot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@
8989

9090
},{"sane-topojson":15}]},{},[16])(16)
9191
});PlotlyGeoAssets.version='1.0.0';
92-
</script><div id="360d69a8-1171-44c0-b83b-1b517e1f2f2b" style="height: 480; width: 640px;" class="plotly-graph-div"></div><script type="text/javascript">window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL="https://plot.ly";Plotly.newPlot("360d69a8-1171-44c0-b83b-1b517e1f2f2b", [{"name": "_line0", "yaxis": "y1", "marker": {"color": "#0000FF", "opacity": 1, "line": {"color": "#000000", "width": 0.5}, "symbol": "dot", "size": 6.0}, "mode": "markers", "xaxis": "x1", "y": [100.0, 200.0, 300.0], "x": [10.0, 20.0, 30.0], "type": "scatter"}], {"autosize": false, "width": 640, "showlegend": false, "xaxis1": {"tickfont": {"size": 12.0}, "___domain": [0.0, 1.0], "ticks": "inside", "showgrid": false, "range": [10.0, 30.0], "mirror": "ticks", "zeroline": false, "showline": true, "nticks": 5, "type": "linear", "anchor": "y1", "side": "bottom"}, "height": 480, "yaxis1": {"tickfont": {"size": 12.0}, "___domain": [0.0, 1.0], "ticks": "inside", "showgrid": false, "range": [100.0, 300.0], "mirror": "ticks", "zeroline": false, "showline": true, "nticks": 5, "type": "linear", "anchor": "x1", "side": "left"}, "hovermode": "closest", "margin": {"b": 47, "r": 63, "pad": 0, "t": 47, "l": 80}}, {"linkText": "Export to plot.ly", "showLink": true})</script></body></html>
92+
</script><div id="ca8677eb-743a-4dc6-a696-08ec47f92962" style="height: 480; width: 640px;" class="plotly-graph-div"></div><script type="text/javascript">window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL="https://plot.ly";Plotly.newPlot("ca8677eb-743a-4dc6-a696-08ec47f92962", [{"name": "_line0", "yaxis": "y1", "marker": {"color": "#0000FF", "opacity": 1, "line": {"color": "#000000", "width": 0.5}, "symbol": "dot", "size": 6.0}, "mode": "markers", "xaxis": "x1", "y": [100.0, 200.0, 300.0], "x": [10.0, 20.0, 30.0], "type": "scatter"}], {"autosize": false, "width": 640, "showlegend": false, "xaxis1": {"tickfont": {"size": 12.0}, "___domain": [0.0, 1.0], "ticks": "inside", "showgrid": false, "range": [10.0, 30.0], "mirror": "ticks", "zeroline": false, "showline": true, "nticks": 5, "type": "linear", "anchor": "y1", "side": "bottom"}, "height": 480, "yaxis1": {"tickfont": {"size": 12.0}, "___domain": [0.0, 1.0], "ticks": "inside", "showgrid": false, "range": [100.0, 300.0], "mirror": "ticks", "zeroline": false, "showline": true, "nticks": 5, "type": "linear", "anchor": "x1", "side": "left"}, "hovermode": "closest", "margin": {"b": 47, "r": 63, "pad": 0, "t": 47, "l": 80}}, {})</script></body></html>

0 commit comments

Comments
 (0)