@@ -616,33 +616,27 @@ def configure_cartesian_axes(args, fig, orders):
616616 if "is_timeline" in args :
617617 fig .update_xaxes (type = "date" )
618618
619- return fig .layout
620-
621619
622620def configure_ternary_axes (args , fig , orders ):
623- fig .update_layout (
624- ternary = dict (
625- aaxis = dict (title_text = get_label (args , args ["a" ])),
626- baxis = dict (title_text = get_label (args , args ["b" ])),
627- caxis = dict (title_text = get_label (args , args ["c" ])),
628- )
621+ fig .update_ternaries (
622+ aaxis = dict (title_text = get_label (args , args ["a" ])),
623+ baxis = dict (title_text = get_label (args , args ["b" ])),
624+ caxis = dict (title_text = get_label (args , args ["c" ])),
629625 )
630626
631627
632628def configure_polar_axes (args , fig , orders ):
633- layout = dict (
634- polar = dict (
635- angularaxis = dict (direction = args ["direction" ], rotation = args ["start_angle" ]),
636- radialaxis = dict (),
637- )
629+ patch = dict (
630+ angularaxis = dict (direction = args ["direction" ], rotation = args ["start_angle" ]),
631+ radialaxis = dict (),
638632 )
639633
640634 for var , axis in [("r" , "radialaxis" ), ("theta" , "angularaxis" )]:
641635 if args [var ] in orders :
642- layout [ "polar" ] [axis ]["categoryorder" ] = "array"
643- layout [ "polar" ] [axis ]["categoryarray" ] = orders [args [var ]]
636+ patch [axis ]["categoryorder" ] = "array"
637+ patch [axis ]["categoryarray" ] = orders [args [var ]]
644638
645- radialaxis = layout [ "polar" ] ["radialaxis" ]
639+ radialaxis = patch ["radialaxis" ]
646640 if args ["log_r" ]:
647641 radialaxis ["type" ] = "log"
648642 if args ["range_r" ]:
@@ -652,21 +646,19 @@ def configure_polar_axes(args, fig, orders):
652646 radialaxis ["range" ] = args ["range_r" ]
653647
654648 if args ["range_theta" ]:
655- layout [ "polar" ] ["sector" ] = args ["range_theta" ]
656- fig .update ( layout = layout )
649+ patch ["sector" ] = args ["range_theta" ]
650+ fig .update_polars ( patch )
657651
658652
659653def configure_3d_axes (args , fig , orders ):
660- layout = dict (
661- scene = dict (
662- xaxis = dict (title_text = get_label (args , args ["x" ])),
663- yaxis = dict (title_text = get_label (args , args ["y" ])),
664- zaxis = dict (title_text = get_label (args , args ["z" ])),
665- )
654+ patch = dict (
655+ xaxis = dict (title_text = get_label (args , args ["x" ])),
656+ yaxis = dict (title_text = get_label (args , args ["y" ])),
657+ zaxis = dict (title_text = get_label (args , args ["z" ])),
666658 )
667659
668660 for letter in ["x" , "y" , "z" ]:
669- axis = layout [ "scene" ] [letter + "axis" ]
661+ axis = patch [letter + "axis" ]
670662 if args ["log_" + letter ]:
671663 axis ["type" ] = "log"
672664 if args ["range_" + letter ]:
@@ -677,7 +669,7 @@ def configure_3d_axes(args, fig, orders):
677669 if args [letter ] in orders :
678670 axis ["categoryorder" ] = "array"
679671 axis ["categoryarray" ] = orders [args [letter ]]
680- fig .update ( layout = layout )
672+ fig .update_scenes ( patch )
681673
682674
683675def configure_mapbox (args , fig , orders ):
@@ -687,23 +679,21 @@ def configure_mapbox(args, fig, orders):
687679 lat = args ["data_frame" ][args ["lat" ]].mean (),
688680 lon = args ["data_frame" ][args ["lon" ]].mean (),
689681 )
690- fig .update_layout (
691- mapbox = dict (
692- accesstoken = MAPBOX_TOKEN ,
693- center = center ,
694- zoom = args ["zoom" ],
695- style = args ["mapbox_style" ],
696- )
682+ fig .update_mapboxes (
683+ accesstoken = MAPBOX_TOKEN ,
684+ center = center ,
685+ zoom = args ["zoom" ],
686+ style = args ["mapbox_style" ],
697687 )
698688
699689
700690def configure_geo (args , fig , orders ):
701- fig .update_layout (
702- geo = dict (
703- center = args ["center " ],
704- scope = args ["scope " ],
705- projection = dict ( type = args ["projection" ]) ,
706- )
691+ fig .update_geos (
692+ center = args [ "center" ],
693+ scope = args ["scope " ],
694+ fitbounds = args ["fitbounds " ],
695+ visible = args ["basemap_visible" ] ,
696+ projection = dict ( type = args [ "projection" ]),
707697 )
708698
709699
@@ -1750,6 +1740,14 @@ def infer_config(args, constructor, trace_patch, layout_patch):
17501740 if "line_shape" in args :
17511741 trace_patch ["line" ] = dict (shape = args ["line_shape" ])
17521742
1743+ if "geojson" in args :
1744+ trace_patch ["featureidkey" ] = args ["featureidkey" ]
1745+ trace_patch ["geojson" ] = (
1746+ args ["geojson" ]
1747+ if not hasattr (args ["geojson" ], "__geo_interface__" ) # for geopandas
1748+ else args ["geojson" ].__geo_interface__
1749+ )
1750+
17531751 # Compute marginal attribute
17541752 if "marginal" in args :
17551753 position = "marginal_x" if args ["orientation" ] == "v" else "marginal_y"
@@ -2062,20 +2060,12 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
20622060
20632061def init_figure (args , subplot_type , frame_list , nrows , ncols , col_labels , row_labels ):
20642062 # Build subplot specs
2065- specs = [[{}] * ncols for _ in range (nrows )]
2066- for frame in frame_list :
2067- for trace in frame ["data" ]:
2068- row0 = trace ._subplot_row - 1
2069- col0 = trace ._subplot_col - 1
2070- if isinstance (trace , go .Splom ):
2071- # Splom not compatible with make_subplots, treat as domain
2072- specs [row0 ][col0 ] = {"type" : "domain" }
2073- else :
2074- specs [row0 ][col0 ] = {"type" : trace .type }
2063+ specs = [[dict (type = subplot_type or "domain" )] * ncols for _ in range (nrows )]
20752064
20762065 # Default row/column widths uniform
20772066 column_widths = [1.0 ] * ncols
20782067 row_heights = [1.0 ] * nrows
2068+ facet_col_wrap = args .get ("facet_col_wrap" , 0 )
20792069
20802070 # Build column_widths/row_heights
20812071 if subplot_type == "xy" :
@@ -2087,7 +2077,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la
20872077
20882078 row_heights = [main_size ] * (nrows - 1 ) + [1 - main_size ]
20892079 vertical_spacing = 0.01
2090- elif args . get ( " facet_col_wrap" , 0 ) :
2080+ elif facet_col_wrap :
20912081 vertical_spacing = args .get ("facet_row_spacing" , None ) or 0.07
20922082 else :
20932083 vertical_spacing = args .get ("facet_row_spacing" , None ) or 0.03
@@ -2108,10 +2098,12 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la
21082098 #
21092099 # We can customize subplot spacing per type once we enable faceting
21102100 # for all plot types
2111- vertical_spacing = 0.1
2112- horizontal_spacing = 0.1
2101+ if facet_col_wrap :
2102+ vertical_spacing = args .get ("facet_row_spacing" , None ) or 0.07
2103+ else :
2104+ vertical_spacing = args .get ("facet_row_spacing" , None ) or 0.03
2105+ horizontal_spacing = args .get ("facet_col_spacing" , None ) or 0.02
21132106
2114- facet_col_wrap = args .get ("facet_col_wrap" , 0 )
21152107 if facet_col_wrap :
21162108 subplot_labels = [None ] * nrows * ncols
21172109 while len (col_labels ) < nrows * ncols :
0 commit comments