@@ -616,33 +616,27 @@ def configure_cartesian_axes(args, fig, orders):
616
616
if "is_timeline" in args :
617
617
fig .update_xaxes (type = "date" )
618
618
619
- return fig .layout
620
-
621
619
622
620
def 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" ])),
629
625
)
630
626
631
627
632
628
def 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 (),
638
632
)
639
633
640
634
for var , axis in [("r" , "radialaxis" ), ("theta" , "angularaxis" )]:
641
635
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 ]]
644
638
645
- radialaxis = layout [ "polar" ] ["radialaxis" ]
639
+ radialaxis = patch ["radialaxis" ]
646
640
if args ["log_r" ]:
647
641
radialaxis ["type" ] = "log"
648
642
if args ["range_r" ]:
@@ -652,21 +646,19 @@ def configure_polar_axes(args, fig, orders):
652
646
radialaxis ["range" ] = args ["range_r" ]
653
647
654
648
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 )
657
651
658
652
659
653
def 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" ])),
666
658
)
667
659
668
660
for letter in ["x" , "y" , "z" ]:
669
- axis = layout [ "scene" ] [letter + "axis" ]
661
+ axis = patch [letter + "axis" ]
670
662
if args ["log_" + letter ]:
671
663
axis ["type" ] = "log"
672
664
if args ["range_" + letter ]:
@@ -677,7 +669,7 @@ def configure_3d_axes(args, fig, orders):
677
669
if args [letter ] in orders :
678
670
axis ["categoryorder" ] = "array"
679
671
axis ["categoryarray" ] = orders [args [letter ]]
680
- fig .update ( layout = layout )
672
+ fig .update_scenes ( patch )
681
673
682
674
683
675
def configure_mapbox (args , fig , orders ):
@@ -687,23 +679,21 @@ def configure_mapbox(args, fig, orders):
687
679
lat = args ["data_frame" ][args ["lat" ]].mean (),
688
680
lon = args ["data_frame" ][args ["lon" ]].mean (),
689
681
)
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" ],
697
687
)
698
688
699
689
700
690
def 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" ]),
707
697
)
708
698
709
699
@@ -1750,6 +1740,14 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1750
1740
if "line_shape" in args :
1751
1741
trace_patch ["line" ] = dict (shape = args ["line_shape" ])
1752
1742
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
+
1753
1751
# Compute marginal attribute
1754
1752
if "marginal" in args :
1755
1753
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):
2062
2060
2063
2061
def init_figure (args , subplot_type , frame_list , nrows , ncols , col_labels , row_labels ):
2064
2062
# 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 )]
2075
2064
2076
2065
# Default row/column widths uniform
2077
2066
column_widths = [1.0 ] * ncols
2078
2067
row_heights = [1.0 ] * nrows
2068
+ facet_col_wrap = args .get ("facet_col_wrap" , 0 )
2079
2069
2080
2070
# Build column_widths/row_heights
2081
2071
if subplot_type == "xy" :
@@ -2087,7 +2077,7 @@ def init_figure(args, subplot_type, frame_list, nrows, ncols, col_labels, row_la
2087
2077
2088
2078
row_heights = [main_size ] * (nrows - 1 ) + [1 - main_size ]
2089
2079
vertical_spacing = 0.01
2090
- elif args . get ( " facet_col_wrap" , 0 ) :
2080
+ elif facet_col_wrap :
2091
2081
vertical_spacing = args .get ("facet_row_spacing" , None ) or 0.07
2092
2082
else :
2093
2083
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
2108
2098
#
2109
2099
# We can customize subplot spacing per type once we enable faceting
2110
2100
# 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
2113
2106
2114
- facet_col_wrap = args .get ("facet_col_wrap" , 0 )
2115
2107
if facet_col_wrap :
2116
2108
subplot_labels = [None ] * nrows * ncols
2117
2109
while len (col_labels ) < nrows * ncols :
0 commit comments