@@ -369,7 +369,7 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):
369369 verify = get_config ()['plotly_ssl_verification' ])
370370 if response .status_code == 200 :
371371 if six .PY3 :
372- content = json .loads (response .content .decode ('unicode_escape ' ))
372+ content = json .loads (response .content .decode ('utf-8 ' ))
373373 else :
374374 content = json .loads (response .content )
375375 response_payload = content ['payload' ]
@@ -406,14 +406,15 @@ class Stream:
406406 Stream example:
407407 # Initialize a streaming graph
408408 # 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))]))
413414 # 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
417418 """
418419
419420 @utils .template_doc (** tools .get_config_file ())
@@ -536,7 +537,7 @@ def write(self, trace, layout=None, validate=True,
536537 stream_object .update (dict (layout = layout ))
537538
538539 # TODO: allow string version of this?
539- jdata = json .dumps (stream_object , cls = utils ._plotlyJSONEncoder )
540+ jdata = json .dumps (stream_object , cls = utils .PlotlyJSONEncoder )
540541 jdata += "\n "
541542
542543 try :
@@ -602,7 +603,7 @@ def get(figure_or_data, format='png', width=None, height=None):
602603
603604 url = get_config ()['plotly_domain' ] + "/apigenimage/"
604605 res = requests .post (
605- url , data = json .dumps (payload , cls = utils ._plotlyJSONEncoder ),
606+ url , data = json .dumps (payload , cls = utils .PlotlyJSONEncoder ),
606607 headers = headers , verify = get_config ()['plotly_ssl_verification' ]
607608 )
608609
@@ -824,7 +825,7 @@ def upload(cls, grid, filename,
824825
825826 payload = {
826827 'filename' : filename ,
827- 'data' : json .dumps (grid_json , cls = utils ._plotlyJSONEncoder ),
828+ 'data' : json .dumps (grid_json , cls = utils .PlotlyJSONEncoder ),
828829 'world_readable' : world_readable
829830 }
830831
@@ -905,7 +906,7 @@ def append_columns(cls, columns, grid=None, grid_url=None):
905906 raise exceptions .InputError (err )
906907
907908 payload = {
908- 'cols' : json .dumps (columns , cls = utils ._plotlyJSONEncoder )
909+ 'cols' : json .dumps (columns , cls = utils .PlotlyJSONEncoder )
909910 }
910911
911912 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):
980981 'column' if n_columns == 1 else 'columns' ))
981982
982983 payload = {
983- 'rows' : json .dumps (rows , cls = utils ._plotlyJSONEncoder )
984+ 'rows' : json .dumps (rows , cls = utils .PlotlyJSONEncoder )
984985 }
985986
986987 api_url = (_api_v2 .api_url ('grids' )+
@@ -1098,7 +1099,7 @@ def upload(cls, meta, grid=None, grid_url=None):
10981099 grid_id = _api_v2 .parse_grid_id_args (grid , grid_url )
10991100
11001101 payload = {
1101- 'metadata' : json .dumps (meta , cls = utils ._plotlyJSONEncoder )
1102+ 'metadata' : json .dumps (meta , cls = utils .PlotlyJSONEncoder )
11021103 }
11031104
11041105 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):
12061207 """
12071208 fig = tools ._replace_newline (figure ) # does not mutate figure
12081209 data = json .dumps (fig ['data' ] if 'data' in fig else [],
1209- cls = utils ._plotlyJSONEncoder )
1210+ cls = utils .PlotlyJSONEncoder )
12101211 username , api_key = _get_session_username_and_key ()
12111212 kwargs = json .dumps (dict (filename = plot_options ['filename' ],
12121213 fileopt = plot_options ['fileopt' ],
12131214 world_readable = plot_options ['world_readable' ],
12141215 layout = fig ['layout' ] if 'layout' in fig
12151216 else {}),
1216- cls = utils ._plotlyJSONEncoder )
1217+ cls = utils .PlotlyJSONEncoder )
12171218
12181219
12191220 payload = dict (platform = 'python' , # TODO: It'd be cool to expose the platform for RaspPi and others
0 commit comments