Skip to content

Issue399 (updated) #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions plotly/graph_reference/default-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand Down
71 changes: 64 additions & 7 deletions plotly/offline/offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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))

Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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)

Expand Down Expand Up @@ -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:
```
Expand Down Expand Up @@ -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:
```
Expand Down Expand Up @@ -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))

92 changes: 92 additions & 0 deletions plotly/temp-plot.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plotly/tests/test_core/test_tools/test_get_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ("<iframe id=\"igraph\" scrolling=\"no\" "
"style=\"border:none;\"seamless=\"seamless\" "
"style=\"border:none;\" seamless=\"seamless\" "
"src=\"{plotly_rest_url}/"
"~{file_owner}/{file_id}.embed?"
"share_key={share_key}\" "
Expand Down
92 changes: 92 additions & 0 deletions temp-plot.html

Large diffs are not rendered by default.