Skip to content

Commit 5482b53

Browse files
committed
merged master offline.py to local - changed call signature in one func
2 parents eb57218 + b3c1d1e commit 5482b53

File tree

9 files changed

+489
-60
lines changed

9 files changed

+489
-60
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
### Updated
7+
- `FF.create_violin` and `FF.create_scatterplotmatrix` now by default do not print subplot grid information in output
8+
9+
### Added
10+
- Plot configuration options for offline plots. See the list of [configuration options](https://github.com/Rikorose/plotly.py/blob/master/plotly/offline/offline.py#L189) and [examples](https://plot.ly/javascript/configuration-options/) for more information.
11+
- Please note that these configuration options are for offline plots ONLY. For configuration options when embedding online plots please see our [embed tutorial](http://help.plot.ly/embed-graphs-in-websites/#step-8-customize-the-iframe).
12+
- `colors.py` file which contains functions for manipulating and validating colors and arrays of colors
13+
- 'scale' param in `FF.create_trisurf` which now can set the interpolation on the colorscales
14+
15+
### Fixed
16+
- Trisurf now uses correct `Plotly Colorscales` when called
17+
518
## [1.12.9] - 2016-08-22
619
### Fixed
720
- the colorbar in `.create_trisurf` now displays properly in `offline mode`.

bld.bat

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"%PYTHON%" setup.py install
2+
if errorlevel 1 exit 1
3+
4+
:: Add more build steps here, if they are necessary.
5+
6+
:: See
7+
:: http://docs.continuum.io/conda/build.html
8+
:: for a list of environment variables that are set during the build process.

build.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
$PYTHON setup.py install
4+
5+
# Add more build steps here, if they are necessary.
6+
7+
# See
8+
# http://docs.continuum.io/conda/build.html
9+
# for a list of environment variables that are set during the build process.

build_for_conda.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Initial setup was done using:
2+
3+
`conda skeleton pypi plotly --version 1.12.4`
4+
5+
To test all imports, manually added following dependencies at runtime:
6+
```
7+
- matplotlib
8+
- numpy
9+
- ipython
10+
- ipywidgets
11+
```
12+
13+
I also had to change all `module/submodule` in the test imports to `module.submodule`.
14+
15+
Finally, build and test the created version:
16+
17+
`conda build plotly`
18+
19+
Currently, the updated (version 1.12.4) conda package sits at https://anaconda.org/chohner/plotly. There seems to be an old offial package at https://anaconda.org/plotly/plotly.

meta.yaml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package:
2+
name: plotly
3+
version: "1.12.4"
4+
5+
source:
6+
fn: plotly-1.12.4.tar.gz
7+
url: https://files.pythonhosted.org/packages/02/e0/5b739403c3180298ebe277cbc9f5ee99e546ab24768b1732a2d6b381091b/plotly-1.12.4.tar.gz
8+
md5: f1ff6b1b18554258aab50449ab571ee2
9+
# patches:
10+
# List any patch files here
11+
# - fix.patch
12+
13+
# build:
14+
# noarch_python: True
15+
# preserve_egg_dir: True
16+
# entry_points:
17+
# Put any entry points (scripts to be generated automatically) here. The
18+
# syntax is module:function. For example
19+
#
20+
# - plotly = plotly:main
21+
#
22+
# Would create an entry point called plotly that calls plotly.main()
23+
24+
25+
# If this is a new build for the same version, increment the build
26+
# number. If you do not include this key, it defaults to 0.
27+
# number: 1
28+
29+
requirements:
30+
build:
31+
- python
32+
- setuptools
33+
- requests
34+
- six
35+
- pytz
36+
37+
run:
38+
- python
39+
- requests
40+
- six
41+
- pytz
42+
- matplotlib
43+
- numpy
44+
- ipython
45+
- ipywidgets
46+
47+
test:
48+
# Python imports
49+
imports:
50+
- plotly
51+
- plotly.graph_objs
52+
- plotly.grid_objs
53+
- plotly.matplotlylib
54+
- plotly.matplotlylib.mplexporter
55+
- plotly.matplotlylib.mplexporter.renderers
56+
- plotly.offline
57+
- plotly.plotly
58+
- plotly.plotly.chunked_requests
59+
- plotly.widgets
60+
61+
# commands:
62+
# You can put test commands to be run here. Use this to test that the
63+
# entry points work.
64+
65+
66+
# You can also put a file called run_test.py in the recipe that will be run
67+
# at test time.
68+
69+
# requires:
70+
# Put any additional test requirements here. For example
71+
# - nose
72+
73+
about:
74+
home: https://plot.ly/python/
75+
license: MIT
76+
summary: 'Python plotting library for collaborative, interactive, publication-quality graphs.'
77+
78+
# See
79+
# http://docs.continuum.io/conda/build.html for
80+
# more information about meta.yaml

plotly/offline/offline.py

+26-6
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def init_notebook_mode(connected=False):
160160
__PLOTLY_OFFLINE_INITIALIZED = True
161161

162162

163-
def _plot_html(figure_or_data, show_link, link_text, validate,
164-
default_width, default_height, global_requirejs):
163+
def _plot_html(figure_or_data, config, validate, default_width,
164+
default_height, global_requirejs):
165165
# force no validation if frames is in the call
166166
if 'frames' in figure_or_data:
167167
figure = tools.return_figure_from_figure_or_data(
@@ -195,10 +195,30 @@ def _plot_html(figure_or_data, show_link, link_text, validate,
195195
if 'frames' in figure_or_data:
196196
jframes = json.dumps(figure.get('frames', {}), cls=utils.PlotlyJSONEncoder)
197197

198-
config = {}
199-
config['showLink'] = show_link
200-
config['linkText'] = link_text
201-
jconfig = json.dumps(config)
198+
configkeys = (
199+
'editable',
200+
'autosizable',
201+
'fillFrame',
202+
'frameMargins',
203+
'scrollZoom',
204+
'doubleClick',
205+
'showTips',
206+
'showLink',
207+
'sendData',
208+
'linkText',
209+
'showSources',
210+
'displayModeBar',
211+
'modeBarButtonsToRemove',
212+
'modeBarButtonsToAdd',
213+
'modeBarButtons',
214+
'displaylogo',
215+
'plotGlPixelRatio',
216+
'setBackground',
217+
'topojsonURL')
218+
219+
config_clean = dict((k,config[k]) for k in configkeys if k in config)
220+
221+
jconfig = json.dumps(config_clean)
202222

203223
# TODO: The get_config 'source of truth' should
204224
# really be somewhere other than plotly.plotly

plotly/plotly/plotly.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ def __init__(self, stream_id):
453453
454454
"""
455455
self.stream_id = stream_id
456-
self.connected = False
457456
self._stream = None
458457

459458
def get_streaming_specs(self):
@@ -499,6 +498,13 @@ def heartbeat(self, reconnect_on=(200, '', 408)):
499498
"cannot write to a closed connection. "
500499
"Call `open()` on the stream to open the stream."
501500
)
501+
502+
@property
503+
def connected(self):
504+
if self._stream is None:
505+
return False
506+
507+
return self._stream._isconnected()
502508

503509
def open(self):
504510
"""
@@ -1289,10 +1295,11 @@ def response_handler(cls, response):
12891295
!= tools.get_config_defaults()['plotly_api_domain']):
12901296
raise exceptions.PlotlyError(
12911297
"This endpoint is unavailable at {url}. If you are using "
1292-
"Plotly Enterprise, you may need to upgrade your Plotly "
1293-
"Enterprise server to request against this endpoint or "
1298+
"Plotly On-Premise, you may need to upgrade your Plotly "
1299+
"Plotly On-Premise server to request against this endpoint or "
12941300
"this endpoint may not be available yet.\nQuestions? "
1295-
"[email protected] or your plotly administrator."
1301+
"Visit community.plot.ly, contact your plotly administrator "
1302+
"or upgrade to a Pro account for 1-1 help: https://goo.gl/1YUVu9 "
12961303
.format(url=get_config()['plotly_api_domain'])
12971304
)
12981305
else:

0 commit comments

Comments
 (0)