@@ -369,7 +369,7 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):
369
369
verify = get_config ()['plotly_ssl_verification' ])
370
370
if response .status_code == 200 :
371
371
if six .PY3 :
372
- content = json .loads (response .content .decode ('unicode_escape ' ))
372
+ content = json .loads (response .content .decode ('utf-8 ' ))
373
373
else :
374
374
content = json .loads (response .content )
375
375
response_payload = content ['payload' ]
@@ -406,14 +406,15 @@ class Stream:
406
406
Stream example:
407
407
# Initialize a streaming graph
408
408
# by embedding stream_id's in the graph's traces
409
- >>> stream_id = "your_stream_id" # See {plotly_domain}/settings
410
- >>> py.plot(Data([Scatter(x=[],
411
- y=[],
412
- stream=dict(token=stream_id, maxpoints=100))])
409
+ import plotly.plotly as py
410
+ from plotly.graph_objs import Data, Scatter, Stream
411
+ stream_id = "your_stream_id" # See {plotly_domain}/settings
412
+ py.plot(Data([Scatter(x=[], y=[],
413
+ stream=Stream(token=stream_id, maxpoints=100))]))
413
414
# Stream data to the import trace
414
- >>> stream = Stream(stream_id) # Initialize a stream object
415
- >>> stream.open() # Open the stream
416
- >>> stream.write(dict(x=1, y=1)) # Plot (1, 1) in your graph
415
+ stream = Stream(stream_id) # Initialize a stream object
416
+ stream.open() # Open the stream
417
+ stream.write(dict(x=1, y=1)) # Plot (1, 1) in your graph
417
418
"""
418
419
419
420
@utils .template_doc (** tools .get_config_file ())
@@ -536,7 +537,7 @@ def write(self, trace, layout=None, validate=True,
536
537
stream_object .update (dict (layout = layout ))
537
538
538
539
# TODO: allow string version of this?
539
- jdata = json .dumps (stream_object , cls = utils ._plotlyJSONEncoder )
540
+ jdata = json .dumps (stream_object , cls = utils .PlotlyJSONEncoder )
540
541
jdata += "\n "
541
542
542
543
try :
@@ -602,7 +603,7 @@ def get(figure_or_data, format='png', width=None, height=None):
602
603
603
604
url = get_config ()['plotly_domain' ] + "/apigenimage/"
604
605
res = requests .post (
605
- url , data = json .dumps (payload , cls = utils ._plotlyJSONEncoder ),
606
+ url , data = json .dumps (payload , cls = utils .PlotlyJSONEncoder ),
606
607
headers = headers , verify = get_config ()['plotly_ssl_verification' ]
607
608
)
608
609
@@ -824,7 +825,7 @@ def upload(cls, grid, filename,
824
825
825
826
payload = {
826
827
'filename' : filename ,
827
- 'data' : json .dumps (grid_json , cls = utils ._plotlyJSONEncoder ),
828
+ 'data' : json .dumps (grid_json , cls = utils .PlotlyJSONEncoder ),
828
829
'world_readable' : world_readable
829
830
}
830
831
@@ -905,7 +906,7 @@ def append_columns(cls, columns, grid=None, grid_url=None):
905
906
raise exceptions .InputError (err )
906
907
907
908
payload = {
908
- 'cols' : json .dumps (columns , cls = utils ._plotlyJSONEncoder )
909
+ 'cols' : json .dumps (columns , cls = utils .PlotlyJSONEncoder )
909
910
}
910
911
911
912
api_url = _api_v2 .api_url ('grids' )+ '/{grid_id}/col' .format (grid_id = grid_id )
@@ -980,7 +981,7 @@ def append_rows(cls, rows, grid=None, grid_url=None):
980
981
'column' if n_columns == 1 else 'columns' ))
981
982
982
983
payload = {
983
- 'rows' : json .dumps (rows , cls = utils ._plotlyJSONEncoder )
984
+ 'rows' : json .dumps (rows , cls = utils .PlotlyJSONEncoder )
984
985
}
985
986
986
987
api_url = (_api_v2 .api_url ('grids' )+
@@ -1098,7 +1099,7 @@ def upload(cls, meta, grid=None, grid_url=None):
1098
1099
grid_id = _api_v2 .parse_grid_id_args (grid , grid_url )
1099
1100
1100
1101
payload = {
1101
- 'metadata' : json .dumps (meta , cls = utils ._plotlyJSONEncoder )
1102
+ 'metadata' : json .dumps (meta , cls = utils .PlotlyJSONEncoder )
1102
1103
}
1103
1104
1104
1105
api_url = _api_v2 .api_url ('grids' )+ '/{grid_id}' .format (grid_id = grid_id )
@@ -1206,14 +1207,14 @@ def _send_to_plotly(figure, **plot_options):
1206
1207
"""
1207
1208
fig = tools ._replace_newline (figure ) # does not mutate figure
1208
1209
data = json .dumps (fig ['data' ] if 'data' in fig else [],
1209
- cls = utils ._plotlyJSONEncoder )
1210
+ cls = utils .PlotlyJSONEncoder )
1210
1211
username , api_key = _get_session_username_and_key ()
1211
1212
kwargs = json .dumps (dict (filename = plot_options ['filename' ],
1212
1213
fileopt = plot_options ['fileopt' ],
1213
1214
world_readable = plot_options ['world_readable' ],
1214
1215
layout = fig ['layout' ] if 'layout' in fig
1215
1216
else {}),
1216
- cls = utils ._plotlyJSONEncoder )
1217
+ cls = utils .PlotlyJSONEncoder )
1217
1218
1218
1219
1219
1220
payload = dict (platform = 'python' , # TODO: It'd be cool to expose the platform for RaspPi and others
0 commit comments