Skip to content

Commit 108109a

Browse files
author
yankev
committed
updated fix
changed required parameters of all functions and updated the descriptions.
1 parent 75ec3e1 commit 108109a

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

plotly/offline/offline.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ def _plot_html(figure_or_data, config,
126126
# really be somewhere other than plotly.plotly
127127
plotly_platform_url = plotly.plotly.get_config().get('plotly_domain',
128128
'https://plot.ly')
129+
129130
if (plotly_platform_url != 'https://plot.ly' and
130-
link_text == 'Export to plot.ly'):
131+
'linkText' in config):
131132

132133
link_domain = plotly_platform_url\
133134
.replace('https://', '')\
134135
.replace('http://', '')
135-
link_text = link_text.replace('plot.ly', link_domain)
136+
137+
config['linkText'] = config['linkText'].replace('plot.ly', link_domain)
136138

137139
script = 'Plotly.newPlot("{id}", {data}, {layout}, {config})'.format(
138140
id=plotdivid,
@@ -157,7 +159,7 @@ def _plot_html(figure_or_data, config,
157159
return plotly_html_div, plotdivid, width, height
158160

159161

160-
def iplot(figure_or_data, config = {'show_link': True, 'link_text': 'Export to plot.ly'},
162+
def iplot(figure_or_data, config = {'showLink': True, 'linkText': 'Export to plot.ly'},
161163
validate=True):
162164
"""
163165
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
172174
graph descriptions.
173175
174176
Keyword arguments:
175-
show_link (default=True) -- display a link in the bottom-right corner of
176-
of the chart that will export the chart to
177-
Plotly Cloud or Plotly Enterprise
178-
link_text (default='Export to plot.ly') -- the text of export link
177+
config -- a dictionary with configuration attributes for the plot,
178+
default contains the following two elements:
179+
showLink (default=True) -- display a link in the bottom-right corner of
180+
of the chart that will export the chart to
181+
Plotly Cloud or Plotly Enterprise
182+
linkText (default='Export to plot.ly') -- the text of export link
179183
validate (default=True) -- validate that all of the keys in the figure
180184
are valid? omit if your version of plotly.js
181185
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
211215
display(HTML(plot_html))
212216

213217

214-
def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot.ly'},
218+
def plot(figure_or_data, config = {'showLink':True, 'linkText':'Export to plot.ly'},
215219
validate=True, output_type='file',
216220
include_plotlyjs=True,
217221
filename='temp-plot.html',
@@ -233,10 +237,12 @@ def plot(figure_or_data, config = {'show_link':True, 'link_text':'Export to plot
233237
graph descriptions.
234238
235239
Keyword arguments:
236-
show_link (default=True) -- display a link in the bottom-right corner of
237-
of the chart that will export the chart to Plotly Cloud or
238-
Plotly Enterprise
239-
link_text (default='Export to plot.ly') -- the text of export link
240+
config -- a dictionary with configuration attributes for the plot,
241+
default contains the following two elements:
242+
showLink (default=True) -- display a link in the bottom-right corner of
243+
of the chart that will export the chart to Plotly Cloud or
244+
Plotly Enterprise
245+
linkText (default='Export to plot.ly') -- the text of export link
240246
validate (default=True) -- validate that all of the keys in the figure
241247
are valid? omit if your version of plotly.js has become outdated
242248
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
331337

332338

333339
def plot_mpl(mpl_fig, resize=False, strip_style=False,
334-
verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'},
340+
verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'},
335341
validate=True, output_type='file', include_plotlyjs=True,
336342
filename='temp-plot.html', auto_open=True):
337343
"""
@@ -349,10 +355,12 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False,
349355
resize (default=False) -- allow plotly to choose the figure size.
350356
strip_style (default=False) -- allow plotly to choose style options.
351357
verbose (default=False) -- print message.
352-
show_link (default=True) -- display a link in the bottom-right corner of
353-
of the chart that will export the chart to Plotly Cloud or
354-
Plotly Enterprise
355-
link_text (default='Export to plot.ly') -- the text of export link
358+
config -- a dictionary with configuration attributes for the plot,
359+
default contains the following two elements:
360+
showLink (default=True) -- display a link in the bottom-right corner of
361+
of the chart that will export the chart to Plotly Cloud or
362+
Plotly Enterprise
363+
linkText (default='Export to plot.ly') -- the text of export link
356364
validate (default=True) -- validate that all of the keys in the figure
357365
are valid? omit if your version of plotly.js has become outdated
358366
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,
399407

400408

401409
def iplot_mpl(mpl_fig, resize=False, strip_style=False,
402-
verbose=False, config = {'show_link':True, 'link_text':'Export to plot.ly'},
410+
verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'},
403411
validate=True):
404412
"""
405413
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,
420428
resize (default=False) -- allow plotly to choose the figure size.
421429
strip_style (default=False) -- allow plotly to choose style options.
422430
verbose (default=False) -- print message.
423-
show_link (default=True) -- display a link in the bottom-right corner of
424-
of the chart that will export the chart to Plotly Cloud or
425-
Plotly Enterprise
426-
show_link (default=True) -- display a link in the bottom-right corner of
427-
of the chart that will export the chart to
428-
Plotly Cloud or Plotly Enterprise
429-
link_text (default='Export to plot.ly') -- the text of export link
431+
config -- a dictionary with configuration attributes for the plot,
432+
default contains the following two elements:
433+
showLink (default=True) -- display a link in the bottom-right corner of
434+
of the chart that will export the chart to
435+
Plotly Cloud or Plotly Enterprise
436+
linkText (default='Export to plot.ly') -- the text of export link
430437
validate (default=True) -- validate that all of the keys in the figure
431438
are valid? omit if your version of plotly.js
432439
has become outdated with your version of
@@ -453,8 +460,8 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False,
453460

454461

455462
def enable_mpl_offline(resize=False, strip_style=False,
456-
verbose=False, show_link=True,
457-
link_text='Export to plot.ly', validate=True):
463+
verbose=False, config = {'showLink':True, 'linkText':'Export to plot.ly'},
464+
validate=True):
458465
"""
459466
Convert mpl plots to locally hosted HTML documents.
460467
@@ -487,5 +494,5 @@ def enable_mpl_offline(resize=False, strip_style=False,
487494
formatter = ip.display_formatter.formatters['text/html']
488495
formatter.for_type(matplotlib.figure.Figure,
489496
lambda fig: iplot_mpl(fig, resize, strip_style, verbose,
490-
show_link, link_text, validate))
497+
config, validate))
491498

0 commit comments

Comments
 (0)