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" }, diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index f2153b94e80..a9cca0beb49 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -72,7 +72,7 @@ def init_notebook_mode(): def _plot_html(figure_or_data, show_link, link_text, - validate, default_width, default_height): + validate, default_width, default_height, **config_options): figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -97,9 +97,32 @@ 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 = {} + configkeys = ( + 'editable', + 'autosizable', + 'fillFrame', + 'frameMargins', + 'scrollZoom', + 'doubleClick', + 'showTips', + 'showLink', + 'sendData', + 'linkText', + 'showSources', + 'displayModeBar', + 'modeBarButtonsToRemove', + 'modeBarButtonsToAdd', + 'modeBarButtons', + 'displaylogo', + 'plotGlPixelRatio', + 'setBackground', + 'topojsonURL') + + config = (dict((k, config_options[k]) for k in config_options + if k in configkeys)) config['showLink'] = show_link config['linkText'] = link_text + jconfig = json.dumps(config) # TODO: The get_config 'source of truth' should @@ -138,7 +161,7 @@ def _plot_html(figure_or_data, show_link, link_text, def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', - validate=True): + validate=True, **config_options): """ Draw plotly graphs inside an IPython notebook without connecting to an external server. @@ -186,7 +209,7 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly', plot_html, plotdivid, width, height = _plot_html( figure_or_data, show_link, link_text, validate, - '100%', 525) + '100%', 525, **config_options) display(HTML(plot_html)) @@ -196,7 +219,7 @@ def plot(figure_or_data, validate=True, output_type='file', include_plotlyjs=True, filename='temp-plot.html', - auto_open=True): + auto_open=True, **config_options): """ Create a plotly graph locally as an HTML document or string. Example: @@ -242,6 +265,17 @@ def plot(figure_or_data, auto_open (default=True) -- If True, open the saved file in a web browser after saving. This argument only applies if `output_type` is 'file'. + **config_options -- This will take in other keywords that will + configure other options of your plot including mode bar buttons and + interactivity in your chart. Take a look at: + https://plot.ly/javascript/configuration-options/ for a full list of + possible keywords. For example we can add the keyword `displaylogo` + to False which would remove the Plotly logo in the top right corner. + ``` + iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}], show_link=True, + link_text="Send Here", displaylogo=False) + ``` + """ if output_type not in ['div', 'file']: raise ValueError( @@ -255,7 +289,7 @@ def plot(figure_or_data, plot_html, plotdivid, width, height = _plot_html( figure_or_data, show_link, link_text, validate, - '100%', '100%') + '100%', '100%', **config_options) figure = tools.return_figure_from_figure_or_data(figure_or_data, validate) @@ -358,6 +392,18 @@ def plot_mpl(mpl_fig, resize=False, strip_style=False, auto_open (default=True) -- If True, open the saved file in a web browser after saving. This argument only applies if `output_type` is 'file'. + **config_options -- This will take in other keywords that will + configure other options of your plot including mode bar buttons and + interactivity in your chart. Take a look at: + https://plot.ly/javascript/configuration-options/ for a full list of + possible keywords. For example we can add the keyword `displaylogo` + to False which would remove the Plotly logo in the top right corner. + + ``` + iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}], show_link=True, + link_text="Send Here", displaylogo=False) + ``` + Example: ``` @@ -413,6 +459,18 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False, has become outdated with your version of graph_reference.json or if you need to include extra, unnecessary keys in your figure. + **config_options -- This will take in other keywords that will + configure other options of your plot including mode bar buttons and + interactivity in your chart. Take a look at: + https://plot.ly/javascript/configuration-options/ for a full list of + possible keywords. For example we can add the keyword `displaylogo` + to False which would remove the Plotly logo in the top right corner. + + ``` + iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}], show_link=True, + link_text="Send Here", displaylogo=False) + ``` + Example: ``` @@ -469,4 +527,3 @@ def enable_mpl_offline(resize=False, strip_style=False, formatter.for_type(matplotlib.figure.Figure, lambda fig: iplot_mpl(fig, resize, strip_style, verbose, show_link, link_text, validate)) - diff --git a/plotly/temp-plot.html b/plotly/temp-plot.html new file mode 100644 index 00000000000..ace3c3dc51b --- /dev/null +++ b/plotly/temp-plot.html @@ -0,0 +1,92 @@ +
\ No newline at end of file diff --git a/plotly/tests/test_core/test_tools/test_get_embed.py b/plotly/tests/test_core/test_tools/test_get_embed.py index 33a210a3b57..6b23f3aed7b 100644 --- a/plotly/tests/test_core/test_tools/test_get_embed.py +++ b/plotly/tests/test_core/test_tools/test_get_embed.py @@ -28,7 +28,7 @@ def test_get_embed_url_with_share_key(self): get_embed_return = tls.get_embed('https://plot.ly/~neda/6572' + '?share_key=AH4MyPlyDyDWYA2cM2kj2m') expected_get_embed = ("