33use plotly:: {
44 color:: Rgb ,
55 common:: { Line , Marker , Mode } ,
6- layout:: {
7- Axis , Center , DragMode , LayoutGeo , Mapbox , MapboxStyle , Margin , Projection , Rotation ,
8- } ,
9- DensityMapbox , Layout , Plot , ScatterGeo , ScatterMapbox ,
6+ layout:: { Axis , Center , DragMode , LayoutGeo , Mapbox , MapboxStyle , Projection , Rotation } ,
7+ Configuration , DensityMapbox , Layout , Plot , ScatterGeo , ScatterMapbox ,
108} ;
119use plotly_utils:: write_example_to_html;
1210
1311fn scatter_mapbox ( show : bool , file_name : & str ) {
1412 let trace = ScatterMapbox :: new ( vec ! [ 45.5017 ] , vec ! [ -73.5673 ] )
1513 . marker ( Marker :: new ( ) . size ( 25 ) . opacity ( 0.9 ) ) ;
1614
17- let layout = Layout :: new ( )
18- . drag_mode ( DragMode :: Zoom )
19- . margin ( Margin :: new ( ) . top ( 0 ) . left ( 0 ) . bottom ( 0 ) . right ( 0 ) )
20- . mapbox (
21- Mapbox :: new ( )
22- . style ( MapboxStyle :: OpenStreetMap )
23- . center ( Center :: new ( 45.5017 , -73.5673 ) )
24- . zoom ( 5 ) ,
25- ) ;
15+ let layout = Layout :: new ( ) . drag_mode ( DragMode :: Zoom ) . mapbox (
16+ Mapbox :: new ( )
17+ . style ( MapboxStyle :: OpenStreetMap )
18+ . center ( Center :: new ( 45.5017 , -73.5673 ) )
19+ . zoom ( 5 ) ,
20+ ) ;
2621
2722 let mut plot = Plot :: new ( ) ;
2823 plot. add_trace ( trace) ;
2924 plot. set_layout ( layout) ;
25+ plot. set_configuration ( Configuration :: default ( ) . responsive ( true ) . fill_frame ( true ) ) ;
3026
3127 let path = write_example_to_html ( & plot, file_name) ;
3228 if show {
@@ -100,35 +96,33 @@ fn scatter_geo(show: bool, file_name: &str) {
10096 plot. add_trace ( trace) ;
10197 }
10298
103- let layout = Layout :: new ( )
104- . drag_mode ( DragMode :: Zoom )
105- . margin ( Margin :: new ( ) . top ( 0 ) . left ( 0 ) . bottom ( 0 ) . right ( 0 ) )
106- . geo (
107- LayoutGeo :: new ( )
108- . showocean ( true )
109- . showlakes ( true )
110- . showcountries ( true )
111- . showland ( true )
112- . oceancolor ( Rgb :: new ( 0 , 255 , 255 ) )
113- . lakecolor ( Rgb :: new ( 0 , 255 , 255 ) )
114- . landcolor ( Rgb :: new ( 230 , 145 , 56 ) )
115- . lataxis (
116- Axis :: new ( )
117- . show_grid ( true )
118- . grid_color ( Rgb :: new ( 102 , 102 , 102 ) ) ,
119- )
120- . lonaxis (
121- Axis :: new ( )
122- . show_grid ( true )
123- . grid_color ( Rgb :: new ( 102 , 102 , 102 ) ) ,
124- )
125- . projection (
126- Projection :: new ( )
127- . projection_type ( plotly:: layout:: ProjectionType :: Orthographic )
128- . rotation ( Rotation :: new ( ) . lon ( -100.0 ) . lat ( 40.0 ) ) ,
129- ) ,
130- ) ;
131-
99+ let layout = Layout :: new ( ) . drag_mode ( DragMode :: Zoom ) . geo (
100+ LayoutGeo :: new ( )
101+ . showocean ( true )
102+ . showlakes ( true )
103+ . showcountries ( true )
104+ . showland ( true )
105+ . oceancolor ( Rgb :: new ( 0 , 255 , 255 ) )
106+ . lakecolor ( Rgb :: new ( 0 , 255 , 255 ) )
107+ . landcolor ( Rgb :: new ( 230 , 145 , 56 ) )
108+ . lataxis (
109+ Axis :: new ( )
110+ . show_grid ( true )
111+ . grid_color ( Rgb :: new ( 102 , 102 , 102 ) ) ,
112+ )
113+ . lonaxis (
114+ Axis :: new ( )
115+ . show_grid ( true )
116+ . grid_color ( Rgb :: new ( 102 , 102 , 102 ) ) ,
117+ )
118+ . projection (
119+ Projection :: new ( )
120+ . projection_type ( plotly:: layout:: ProjectionType :: Orthographic )
121+ . rotation ( Rotation :: new ( ) . lon ( -100.0 ) . lat ( 40.0 ) ) ,
122+ ) ,
123+ ) ;
124+
125+ plot. set_configuration ( Configuration :: default ( ) . responsive ( true ) . fill_frame ( true ) ) ;
132126 plot. set_layout ( layout) ;
133127
134128 let path = write_example_to_html ( & plot, file_name) ;
@@ -140,19 +134,17 @@ fn scatter_geo(show: bool, file_name: &str) {
140134fn density_mapbox ( show : bool , file_name : & str ) {
141135 let trace = DensityMapbox :: new ( vec ! [ 45.5017 ] , vec ! [ -73.5673 ] , vec ! [ 0.75 ] ) . zauto ( true ) ;
142136
143- let layout = Layout :: new ( )
144- . drag_mode ( DragMode :: Zoom )
145- . margin ( Margin :: new ( ) . top ( 0 ) . left ( 0 ) . bottom ( 0 ) . right ( 0 ) )
146- . mapbox (
147- Mapbox :: new ( )
148- . style ( MapboxStyle :: OpenStreetMap )
149- . center ( Center :: new ( 45.5017 , -73.5673 ) )
150- . zoom ( 5 ) ,
151- ) ;
137+ let layout = Layout :: new ( ) . drag_mode ( DragMode :: Zoom ) . mapbox (
138+ Mapbox :: new ( )
139+ . style ( MapboxStyle :: OpenStreetMap )
140+ . center ( Center :: new ( 45.5017 , -73.5673 ) )
141+ . zoom ( 5 ) ,
142+ ) ;
152143
153144 let mut plot = Plot :: new ( ) ;
154145 plot. add_trace ( trace) ;
155146 plot. set_layout ( layout) ;
147+ plot. set_configuration ( Configuration :: default ( ) . responsive ( true ) . fill_frame ( true ) ) ;
156148
157149 let path = write_example_to_html ( & plot, file_name) ;
158150 if show {
0 commit comments