7
7
from collections import OrderedDict
8
8
9
9
from plotly import exceptions
10
- from plotly .graph_objs import graph_objs
10
+ from plotly .graph_objs . graph_objs import GraphObjectFactory
11
11
from plotly .tools import (_numpy_imported , _scipy_imported ,
12
12
_scipy__spatial_imported ,
13
13
_scipy__cluster__hierarchy_imported )
@@ -284,14 +284,13 @@ def create_quiver(x, y, u, v, scale=.1, arrow_scale=.3,
284
284
arrow_scale , angle ).get_barbs ()
285
285
arrow_x , arrow_y = _Quiver (x , y , u , v , scale ,
286
286
arrow_scale , angle ).get_quiver_arrows ()
287
- quiver = graph_objs .Scatter (x = barb_x + arrow_x ,
288
- y = barb_y + arrow_y ,
289
- mode = 'lines' , ** kwargs )
287
+ quiver = dict (x = barb_x + arrow_x , y = barb_y + arrow_y ,
288
+ mode = 'lines' , ** kwargs )
290
289
291
290
data = [quiver ]
292
- layout = graph_objs . Layout (hovermode = 'closest' )
291
+ layout = dict (hovermode = 'closest' )
293
292
294
- return graph_objs . Figure ( data = data , layout = layout )
293
+ return GraphObjectFactory . create ( 'figure' , data = data , layout = layout )
295
294
296
295
@staticmethod
297
296
def create_streamline (x , y , u , v ,
@@ -381,7 +380,7 @@ def create_streamline(x, y, u, v,
381
380
FigureFactory ._validate_equal_length (u , v )
382
381
FigureFactory ._validate_streamline (x , y )
383
382
FigureFactory ._validate_positive_scalars (density = density ,
384
- arrow_scale = arrow_scale )
383
+ arrow_scale = arrow_scale )
385
384
386
385
streamline_x , streamline_y = _Streamline (x , y , u , v ,
387
386
density , angle ,
@@ -390,14 +389,13 @@ def create_streamline(x, y, u, v,
390
389
density , angle ,
391
390
arrow_scale ).get_streamline_arrows ()
392
391
393
- streamline = graph_objs .Scatter (x = streamline_x + arrow_x ,
394
- y = streamline_y + arrow_y ,
395
- mode = 'lines' , ** kwargs )
392
+ streamline = dict (x = streamline_x + arrow_x , y = streamline_y + arrow_y ,
393
+ mode = 'lines' , ** kwargs )
396
394
397
395
data = [streamline ]
398
- layout = graph_objs . Layout (hovermode = 'closest' )
396
+ layout = dict (hovermode = 'closest' )
399
397
400
- return graph_objs . Figure ( data = data , layout = layout )
398
+ return GraphObjectFactory . create ( 'figure' , data = data , layout = layout )
401
399
402
400
@staticmethod
403
401
def _make_increasing_ohlc (open , high , low , close , dates , ** kwargs ):
@@ -636,10 +634,9 @@ def create_ohlc(open, high, low, close,
636
634
dates , ** kwargs )
637
635
data = [ohlc_incr , ohlc_decr ]
638
636
639
- layout = graph_objs .Layout (xaxis = dict (zeroline = False ),
640
- hovermode = 'closest' )
637
+ layout = dict (xaxis = dict (zeroline = False ), hovermode = 'closest' )
641
638
642
- return graph_objs . Figure ( data = data , layout = layout )
639
+ return GraphObjectFactory . create ( 'figure' , data = data , layout = layout )
643
640
644
641
@staticmethod
645
642
def _make_increasing_candle (open , high , low , close , dates , ** kwargs ):
@@ -871,8 +868,7 @@ def create_candlestick(open, high, low, close,
871
868
open , high , low , close , dates , ** kwargs )
872
869
data = candle_incr_data + candle_decr_data
873
870
874
- layout = graph_objs .Layout ()
875
- return graph_objs .Figure (data = data , layout = layout )
871
+ return GraphObjectFactory .create ('figure' , data = data , layout = {})
876
872
877
873
@staticmethod
878
874
def create_distplot (hist_data , group_labels ,
@@ -1025,7 +1021,7 @@ def create_distplot(hist_data, group_labels,
1025
1021
data .append (curve )
1026
1022
if show_rug :
1027
1023
data .append (rug )
1028
- layout = graph_objs . Layout (
1024
+ layout = dict (
1029
1025
barmode = 'overlay' ,
1030
1026
hovermode = 'closest' ,
1031
1027
legend = dict (traceorder = 'reversed' ),
@@ -1040,7 +1036,7 @@ def create_distplot(hist_data, group_labels,
1040
1036
dtick = 1 ,
1041
1037
showticklabels = False ))
1042
1038
else :
1043
- layout = graph_objs . Layout (
1039
+ layout = dict (
1044
1040
barmode = 'overlay' ,
1045
1041
hovermode = 'closest' ,
1046
1042
legend = dict (traceorder = 'reversed' ),
@@ -1052,7 +1048,7 @@ def create_distplot(hist_data, group_labels,
1052
1048
position = 0.0 ))
1053
1049
1054
1050
data = sum (data , [])
1055
- return graph_objs . Figure ( data = data , layout = layout )
1051
+ return GraphObjectFactory . create ( 'figure' , data = data , layout = layout )
1056
1052
1057
1053
@staticmethod
1058
1054
def create_dendrogram (X , orientation = "bottom" , labels = None ,
@@ -1872,7 +1868,7 @@ def __init__(self, X, orientation='bottom', labels=None, colorscale=None,
1872
1868
self .zero_vals .sort ()
1873
1869
1874
1870
self .layout = self .set_figure_layout (width , height )
1875
- self .data = graph_objs . Data (dd_traces )
1871
+ self .data = list (dd_traces )
1876
1872
1877
1873
def get_color_dict (self , colorscale ):
1878
1874
"""
@@ -2007,11 +2003,11 @@ def get_dendrogram_traces(self, X, colorscale):
2007
2003
else :
2008
2004
ys = icoord [i ]
2009
2005
color_key = color_list [i ]
2010
- trace = graph_objs . Scatter (
2006
+ trace = dict (
2011
2007
x = np .multiply (self .sign [self .xaxis ], xs ),
2012
2008
y = np .multiply (self .sign [self .yaxis ], ys ),
2013
2009
mode = 'lines' ,
2014
- marker = graph_objs . Marker (color = colors [color_key ])
2010
+ marker = dict (color = colors [color_key ])
2015
2011
)
2016
2012
2017
2013
try :
0 commit comments