@@ -1482,13 +1482,11 @@ def _validate_colors(colors, colortype='tuple'):
1482
1482
from numbers import Number
1483
1483
if colors is None :
1484
1484
colors = DEFAULT_PLOTLY_COLORS
1485
- #colors = [DEFAULT_PLOTLY_COLORS[0],
1486
- # DEFAULT_PLOTLY_COLORS[1]]
1487
1485
1488
1486
if isinstance (colors , str ):
1489
1487
if colors in PLOTLY_SCALES :
1490
1488
colors = PLOTLY_SCALES [colors ]
1491
- if 'rgb' in colors or '#' in colors :
1489
+ elif 'rgb' in colors or '#' in colors :
1492
1490
colors = [colors ]
1493
1491
else :
1494
1492
raise exceptions .PlotlyError (
@@ -3004,11 +3002,16 @@ def _scatterplot_theme(dataframe, headers, diag, size, height,
3004
3002
3005
3003
# Convert colormap to list of n RGB tuples
3006
3004
if colormap_type == 'seq' :
3007
- foo = FigureFactory ._unlabel_rgb (colormap )
3005
+ foo = FigureFactory ._color_parser (
3006
+ colormap , FigureFactory ._unlabel_rgb
3007
+ )
3008
3008
foo = FigureFactory ._n_colors (foo [0 ],
3009
3009
foo [1 ],
3010
3010
n_colors_len )
3011
- theme = FigureFactory ._label_rgb (foo )
3011
+ theme = FigureFactory ._color_parser (
3012
+ foo , FigureFactory ._label_rgb
3013
+ )
3014
+
3012
3015
if colormap_type == 'cat' :
3013
3016
# leave list of colors the same way
3014
3017
theme = colormap
@@ -3173,11 +3176,22 @@ def _scatterplot_theme(dataframe, headers, diag, size, height,
3173
3176
3174
3177
# Convert colormap to list of n RGB tuples
3175
3178
if colormap_type == 'seq' :
3176
- foo = FigureFactory ._unlabel_rgb (colormap )
3179
+ foo = FigureFactory ._color_parser (
3180
+ colormap , FigureFactory ._unlabel_rgb
3181
+ )
3177
3182
foo = FigureFactory ._n_colors (foo [0 ],
3178
3183
foo [1 ],
3179
3184
len (intervals ))
3180
- theme = FigureFactory ._label_rgb (foo )
3185
+ theme = FigureFactory ._color_parser (
3186
+ foo , FigureFactory ._label_rgb
3187
+ )
3188
+
3189
+
3190
+ #foo = FigureFactory._unlabel_rgb(colormap)
3191
+ #foo = FigureFactory._n_colors(foo[0],
3192
+ # foo[1],
3193
+ # len(intervals))
3194
+ #theme = FigureFactory._label_rgb(foo)
3181
3195
if colormap_type == 'cat' :
3182
3196
# leave list of colors the same way
3183
3197
theme = colormap
@@ -3908,154 +3922,16 @@ def create_scatterplotmatrix(df, index=None, endpts=None, diag='scatter',
3908
3922
headers = []
3909
3923
if index_vals is None :
3910
3924
index_vals = []
3911
- plotly_scales = {'Greys' : ['rgb(0,0,0)' , 'rgb(255,255,255)' ],
3912
- 'YlGnBu' : ['rgb(8,29,88)' , 'rgb(255,255,217)' ],
3913
- 'Greens' : ['rgb(0,68,27)' , 'rgb(247,252,245)' ],
3914
- 'YlOrRd' : ['rgb(128,0,38)' , 'rgb(255,255,204)' ],
3915
- 'Bluered' : ['rgb(0,0,255)' , 'rgb(255,0,0)' ],
3916
- 'RdBu' : ['rgb(5,10,172)' , 'rgb(178,10,28)' ],
3917
- 'Reds' : ['rgb(220,220,220)' , 'rgb(178,10,28)' ],
3918
- 'Blues' : ['rgb(5,10,172)' , 'rgb(220,220,220)' ],
3919
- 'Picnic' : ['rgb(0,0,255)' , 'rgb(255,0,0)' ],
3920
- 'Rainbow' : ['rgb(150,0,90)' , 'rgb(255,0,0)' ],
3921
- 'Portland' : ['rgb(12,51,131)' , 'rgb(217,30,30)' ],
3922
- 'Jet' : ['rgb(0,0,131)' , 'rgb(128,0,0)' ],
3923
- 'Hot' : ['rgb(0,0,0)' , 'rgb(255,255,255)' ],
3924
- 'Blackbody' : ['rgb(0,0,0)' , 'rgb(160,200,255)' ],
3925
- 'Earth' : ['rgb(0,0,130)' , 'rgb(255,255,255)' ],
3926
- 'Electric' : ['rgb(0,0,0)' , 'rgb(255,250,220)' ],
3927
- 'Viridis' : ['rgb(68,1,84)' , 'rgb(253,231,37)' ]}
3928
3925
3929
3926
FigureFactory ._validate_scatterplotmatrix (df , index , diag ,
3930
3927
colormap_type , ** kwargs )
3931
3928
3932
3929
# Validate colormap
3933
- if colormap is None :
3934
- colormap = DEFAULT_PLOTLY_COLORS
3935
-
3936
- if isinstance (colormap , str ):
3937
- if colormap in plotly_scales :
3938
- colormap = plotly_scales [colormap ]
3939
-
3940
- elif 'rgb' in colormap :
3941
- colormap = FigureFactory ._unlabel_rgb (colormap )
3942
- for value in colormap :
3943
- if value > 255.0 :
3944
- raise exceptions .PlotlyError ("Whoops! The "
3945
- "elements in your "
3946
- "rgb colormap "
3947
- "tuples cannot "
3948
- "exceed 255.0." )
3949
- colormap = FigureFactory ._label_rgb (colormap )
3950
-
3951
- # put colormap in list
3952
- colors_list = []
3953
- colors_list .append (colormap )
3954
- colormap = colors_list
3955
-
3956
- elif '#' in colormap :
3957
- colormap = FigureFactory ._hex_to_rgb (colormap )
3958
- colormap = FigureFactory ._label_rgb (colormap )
3959
-
3960
- # put colormap in list
3961
- colors_list = []
3962
- colors_list .append (colormap )
3963
- colormap = colors_list
3964
-
3965
- else :
3966
- scale_keys = list (plotly_scales .keys ())
3967
- raise exceptions .PlotlyError ("If you input a string "
3968
- "for 'colormap', it must "
3969
- "either be a Plotly "
3970
- "colorscale, an 'rgb' "
3971
- "color or a hex color."
3972
- "Valid plotly colorscale "
3973
- "names are {}" .format (scale_keys ))
3974
- elif isinstance (colormap , tuple ):
3975
- for value in colormap :
3976
- if value > 1.0 :
3977
- raise exceptions .PlotlyError ("Whoops! The "
3978
- "elements in "
3979
- "your colormap "
3980
- "tuples cannot "
3981
- "exceed 1.0." )
3982
-
3983
- colors_list = []
3984
- colors_list .append (colormap )
3985
- colormap = colors_list
3986
-
3987
- colormap = FigureFactory ._convert_to_RGB_255 (colormap )
3988
- colormap = FigureFactory ._label_rgb (colormap )
3989
-
3990
- elif isinstance (colormap , list ):
3991
- new_colormap = []
3992
- for color in colormap :
3993
- if 'rgb' in color :
3994
- color = FigureFactory ._unlabel_rgb (color )
3995
-
3996
- for value in color :
3997
- if value > 255.0 :
3998
- raise exceptions .PlotlyError ("Whoops! The "
3999
- "elements in your "
4000
- "rgb colormap "
4001
- "tuples cannot "
4002
- "exceed 255.0." )
4003
-
4004
- color = FigureFactory ._label_rgb (color )
4005
- new_colormap .append (color )
4006
- elif '#' in color :
4007
- color = FigureFactory ._hex_to_rgb (color )
4008
- color = FigureFactory ._label_rgb (color )
4009
- new_colormap .append (color )
4010
- elif isinstance (color , tuple ):
4011
- for value in color :
4012
- if value > 1.0 :
4013
- raise exceptions .PlotlyError ("Whoops! The "
4014
- "elements in "
4015
- "your colormap "
4016
- "tuples cannot "
4017
- "exceed 1.0." )
4018
- color = FigureFactory ._convert_to_RGB_255 (color )
4019
- color = FigureFactory ._label_rgb (color )
4020
- new_colormap .append (color )
4021
- colormap = new_colormap
4022
-
4023
- elif isinstance (colormap , dict ):
4024
- for name in colormap :
4025
- if 'rgb' in colormap [name ]:
4026
- color = FigureFactory ._unlabel_rgb (colormap [name ])
4027
- for value in color :
4028
- if value > 255.0 :
4029
- raise exceptions .PlotlyError ("Whoops! The "
4030
- "elements in your "
4031
- "rgb colormap "
4032
- "tuples cannot "
4033
- "exceed 255.0." )
4034
-
4035
- elif '#' in colormap [name ]:
4036
- color = FigureFactory ._hex_to_rgb (colormap [name ])
4037
- color = FigureFactory ._label_rgb (color )
4038
- colormap [name ] = color
4039
-
4040
- elif isinstance (colormap [name ], tuple ):
4041
- for value in colormap [name ]:
4042
- if value > 1.0 :
4043
- raise exceptions .PlotlyError ("Whoops! The "
4044
- "elements in "
4045
- "your colormap "
4046
- "tuples cannot "
4047
- "exceed 1.0." )
4048
- color = FigureFactory ._convert_to_RGB_255 (colormap [name ])
4049
- color = FigureFactory ._label_rgb (color )
4050
- colormap [name ] = color
4051
-
3930
+ if isinstance (colormap , dict ):
3931
+ colormap = FigureFactory ._validate_colors_dict (colormap , 'rgb' )
4052
3932
else :
4053
- raise exceptions .PlotlyError ("You must input a valid colormap. "
4054
- "Valid types include a plotly scale, "
4055
- "rgb, hex or tuple color, a list of "
4056
- "any color types, or a dictionary "
4057
- "with index names each assigned "
4058
- "to a color." )
3933
+ colormap = FigureFactory ._validate_colors (colormap , 'rgb' )
3934
+
4059
3935
if not index :
4060
3936
for name in df :
4061
3937
headers .append (name )
@@ -4094,29 +3970,19 @@ def create_scatterplotmatrix(df, index=None, endpts=None, diag='scatter',
4094
3970
"dictionary, all the "
4095
3971
"names in the index "
4096
3972
"must be keys." )
4097
-
4098
- figure = FigureFactory ._scatterplot_dict (dataframe ,
4099
- headers ,
4100
- diag ,
4101
- size , height ,
4102
- width , title ,
4103
- index ,
4104
- index_vals ,
4105
- endpts ,
4106
- colormap ,
4107
- colormap_type ,
4108
- ** kwargs )
3973
+ figure = FigureFactory ._scatterplot_dict (
3974
+ dataframe , headers , diag , size , height , width , title ,
3975
+ index , index_vals , endpts , colormap , colormap_type ,
3976
+ ** kwargs
3977
+ )
4109
3978
return figure
4110
3979
4111
3980
else :
4112
- figure = FigureFactory ._scatterplot_theme (dataframe , headers ,
4113
- diag , size ,
4114
- height , width ,
4115
- title , index ,
4116
- index_vals ,
4117
- endpts , colormap ,
4118
- colormap_type ,
4119
- ** kwargs )
3981
+ figure = FigureFactory ._scatterplot_theme (
3982
+ dataframe , headers , diag , size , height , width , title ,
3983
+ index , index_vals , endpts , colormap , colormap_type ,
3984
+ ** kwargs
3985
+ )
4120
3986
return figure
4121
3987
4122
3988
@staticmethod
0 commit comments