@@ -659,6 +659,28 @@ def apply_default_cascade(args):
659
659
if args ["color_discrete_sequence" ] is None :
660
660
args ["color_discrete_sequence" ] = qualitative .Plotly
661
661
662
+ def has_value (collection , key ):
663
+ return collection .get (key , None ) is not None
664
+
665
+ def build_dataframe (args , attrables ):
666
+ """
667
+ Constructs an implicit dataframe and modifies `args` in-place.
668
+
669
+ `attrables` is a list of keys into `args`, all of whose corresponding
670
+ values are converted into columns of a dataframe.
671
+
672
+ Used to be support calls to plotting function that elide a dataframe argument;
673
+ for example `scatter(x=[1,2], y=[3,4])`.
674
+ """
675
+ data_frame_columns = {}
676
+ for field in attrables :
677
+ if not has_value (args , field ):
678
+ continue
679
+ data_frame_columns [field ] = args [field ]
680
+ # This sets the label of an attribute to be the name of the attribute.
681
+ args [field ] = field
682
+ args ["data_frame" ] = pandas .DataFrame (data_frame_columns )
683
+ return args
662
684
663
685
def infer_config (args , constructor , trace_patch ):
664
686
attrables = (
@@ -791,29 +813,6 @@ def get_orderings(args, grouper, grouped):
791
813
792
814
return orders , group_names
793
815
794
- def has_value (d , key ):
795
- return d .get (key , None ) is not None
796
-
797
- def build_dataframe (args , attrables ):
798
- """
799
- Constructs an implicit dataframe and modifies `args` in-place.
800
-
801
- `attrables` is a list of keys into `args`, all of whose corresponding
802
- values are converted into columns of a dataframe.
803
-
804
- Used to be support calls to plotting function that elide a dataframe argument;
805
- for example `scatter(x=[1,2], y=[3,4])`.
806
- """
807
- dataset_fields = {}
808
- for field in attrables :
809
- if not has_value (args , field ):
810
- continue
811
- dataset_fields [field ] = args [field ]
812
- # This sets the label of an attribute to be the name of the attribute.
813
- args [field ] = field
814
- args ["data_frame" ] = pandas .DataFrame (dataset_fields )
815
- return args
816
-
817
816
def make_figure (args , constructor , trace_patch = {}, layout_patch = {}):
818
817
apply_default_cascade (args )
819
818
trace_specs , grouped_mappings , sizeref , show_colorbar = infer_config (
0 commit comments