@@ -26,7 +26,14 @@ def make_hist_plot(df, x_var, color_by, sort_by):
26
26
color = color_by ,
27
27
color_discrete_sequence = px .colors .qualitative .Bold ).update_xaxes (categoryorder = sort_by )
28
28
29
- fig .update_layout (title = {'text' : f'Distribution of { x_var } Colored by { color_by } ' })
29
+ fig .update_layout (title = {'text' : f'Distribution of { x_var } Colored by { color_by } ' },
30
+ font = {'size' : 16 },
31
+ margin = {
32
+ 'l' : 30 ,
33
+ 'r' : 20 ,
34
+ 't' : 35 ,
35
+ 'b' : 20
36
+ })
30
37
31
38
return fig
32
39
@@ -46,23 +53,16 @@ def make_map(df, color_by):
46
53
df = df .copy ()
47
54
# only use entries that have valid lat & lon for mapping
48
55
df = df .loc [df ['lat-lon' ].str .contains ('unknown' ) == False ]
49
- fig = px .scatter_geo (df ,
50
- lat = df . lat ,
51
- lon = df . lon ,
52
- projection = "natural earth" ,
56
+ fig = px .scatter_mapbox (df ,
57
+ lat = " lat" ,
58
+ lon = " lon" ,
59
+ # projection = "natural earth",
53
60
custom_data = ["Samples_at_locality" , "Species_at_locality" , "Subspecies_at_locality" ],
54
- size = df . Samples_at_locality ,
61
+ size = " Samples_at_locality" ,
55
62
color = color_by ,
56
63
color_discrete_sequence = px .colors .qualitative .Bold ,
57
64
title = "Distribution of Samples" )
58
65
59
- fig .update_geos (fitbounds = "locations" ,
60
- showcountries = True , countrycolor = "Grey" ,
61
- showrivers = True ,
62
- showlakes = True ,
63
- showland = True , landcolor = "wheat" ,
64
- showocean = True , oceancolor = "LightBlue" )
65
-
66
66
fig .update_traces (hovertemplate =
67
67
"Latitude: %{lat}<br>" +
68
68
"Longitude: %{lon}<br>" +
@@ -71,6 +71,25 @@ def make_map(df, color_by):
71
71
"Subspecies at lat/lon: %{customdata[2]}<br>"
72
72
)
73
73
74
+ fig .update_layout (
75
+ font = {'size' : 16 },
76
+ margin = {
77
+ 'l' : 20 ,
78
+ 'r' : 20 ,
79
+ 't' : 35 ,
80
+ 'b' : 20
81
+ },
82
+ mapbox_style = "white-bg" ,
83
+ mapbox_layers = [{
84
+ "below" : "traces" ,
85
+ "sourcetype" : "raster" ,
86
+ "sourceattribution" : "Esri, Maxar, Earthstar Geographics, and the GIS User Community" ,
87
+ "source" : ["https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}" ]
88
+ # Usage and Licensing (ArcGIS World Imagery): https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
89
+ # Style: https://roblabs.com/xyz-raster-sources/styles/arcgis-world-imagery.json
90
+ }]
91
+ )
92
+
74
93
return fig
75
94
76
95
def make_pie_plot (df , var ):
@@ -97,6 +116,13 @@ def make_pie_plot(df, var):
97
116
color_discrete_sequence = px .colors .qualitative .Bold )
98
117
pie_fig .update_traces (textposition = 'inside' , textinfo = 'percent+label' )
99
118
100
- pie_fig .update_layout (title = {'text' : f'Percentage Breakdown of { var } ' })
119
+ pie_fig .update_layout (title = {'text' : f'Percentage Breakdown of { var } ' },
120
+ font = {'size' : 16 },
121
+ margin = {
122
+ 'l' : 20 ,
123
+ 'r' : 20 ,
124
+ 't' : 35 ,
125
+ 'b' : 20
126
+ })
101
127
102
128
return pie_fig
0 commit comments