19
19
# Declare all supported attributes, across all plot types
20
20
direct_attrables = (
21
21
["x" , "y" , "z" , "a" , "b" , "c" , "r" , "theta" , "size" ]
22
- + ["hover_name" , "text" , "names" , "values" , "parents" ]
22
+ + ["hover_name" , "text" , "names" , "values" , "parents" , "wide_cross" ]
23
23
+ ["ids" , "error_x" , "error_x_minus" , "error_y" , "error_y_minus" , "error_z" ]
24
24
+ ["error_z_minus" , "lat" , "lon" , "locations" , "animation_group" ]
25
25
)
@@ -952,10 +952,11 @@ def build_dataframe(args, constructor):
952
952
953
953
if wide_mode :
954
954
# currently assuming that df_provided == True
955
- args ["wide_cols" ] = [df_input .index ] + list (df_input .columns )
955
+ args ["wide_cols" ] = list (df_input .columns )
956
+ args ["wide_cross" ] = df_input .index
956
957
var_name = df_input .columns .name or "_column_"
957
- index_name = df_input . index . name or "index "
958
- wide_id_vars . add ( index_name )
958
+ wide_orientation = args . get ( "orientation" , None ) or "v "
959
+ args [ "orientation" ] = wide_orientation
959
960
960
961
"""
961
962
wide_x detection
@@ -973,10 +974,11 @@ def build_dataframe(args, constructor):
973
974
- else = long mode
974
975
975
976
so what we want is:
976
- - y = [col col] -> melt just those
977
- - x = [col col] -> melt just those but swap the orientation? except in hist mode
978
- - y = [col col] / x=col -> melt just those and force x to not be the index ... what about hist
977
+ - y = [col col] -> melt just those, wide_orientation = 'v'/no override, cross_dim = index or range
978
+ - y = [col col] / x=col -> wide_orientation = 'h'/no override, cross_dim = x
979
979
- y = [col col] / x=[col col] -> error
980
+
981
+ need to merge wide logic into no_x/no_y logic below for range() etc
980
982
"""
981
983
982
984
df_output = pd .DataFrame ()
@@ -1161,22 +1163,24 @@ def build_dataframe(args, constructor):
1161
1163
if wide_mode :
1162
1164
wide_value_vars = [c for c in args ["wide_cols" ] if c not in wide_id_vars ]
1163
1165
del args ["wide_cols" ]
1166
+ wide_cross = args ["wide_cross" ]
1167
+ del args ["wide_cross" ]
1164
1168
df_output = df_output .melt (
1165
1169
id_vars = wide_id_vars ,
1166
1170
value_vars = wide_value_vars ,
1167
1171
var_name = var_name ,
1168
1172
value_name = "_value_" ,
1169
1173
)
1170
1174
df_output [var_name ] = df_output [var_name ].astype (str )
1171
- args [ "orientation" ] = args . get ( "orientation" , None ) or "v"
1172
- orient_v = args [ "orientation" ] == "v"
1175
+ orient_v = wide_orientation == "v"
1176
+
1173
1177
if constructor == go .Scatter :
1174
- args ["x" if orient_v else "y" ] = index_name
1178
+ args ["x" if orient_v else "y" ] = wide_cross
1175
1179
args ["y" if orient_v else "x" ] = "_value_"
1176
1180
args ["color" ] = args ["color" ] or var_name
1177
1181
if constructor == go .Bar :
1178
1182
if _is_continuous (df_output , "_value_" ):
1179
- args ["x" if orient_v else "y" ] = index_name
1183
+ args ["x" if orient_v else "y" ] = wide_cross
1180
1184
args ["y" if orient_v else "x" ] = "_value_"
1181
1185
args ["color" ] = args ["color" ] or var_name
1182
1186
else :
0 commit comments