Skip to content

Commit 9e364d8

Browse files
update the plot detailes
1 parent a67fa54 commit 9e364d8

File tree

6 files changed

+44
-35
lines changed

6 files changed

+44
-35
lines changed

dist/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*
49.9 KB
Binary file not shown.

dist/fimeval-0.1.56.tar.gz

64 KB
Binary file not shown.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fimeval"
3-
version = "0.1.55"
3+
version = "0.1.56"
44
description = "A Framework for Automatic Evaluation of Flood Inundation Mapping Predictions Evaluation"
55
readme = "README.md"
66
requires-python = ">=3.10"

src/fimeval/BuildingFootprint/evaluationwithBF.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import plotly.graph_objects as go
99
import seaborn as sns
1010
import matplotlib.pyplot as plt
11+
import matplotlib.gridspec as gridspec
1112

1213

1314
def Changeintogpkg(input_path, output_dir, layer_name):
@@ -209,7 +210,7 @@ def count_centroids_in_contingency(raster_path):
209210
)
210211
fig.show()
211212

212-
# Seaborn for static PNG saving only
213+
# Seaborn for static PNG
213214
df_left = pd.DataFrame(
214215
{
215216
"Category": ["Candidate", "Benchmark"],
@@ -224,56 +225,65 @@ def count_centroids_in_contingency(raster_path):
224225
)
225226

226227
sns.set_theme(style="whitegrid")
227-
fig_sb, axes = plt.subplots(1, 2, figsize=(8, 3), constrained_layout=True)
228+
229+
fig_sb = plt.figure(figsize=(10, 3), constrained_layout=True)
230+
gs = gridspec.GridSpec(1, 3, figure=fig_sb, width_ratios=[1, 1, 0.4])
231+
232+
ax0 = fig_sb.add_subplot(gs[0, 0])
233+
ax1 = fig_sb.add_subplot(gs[0, 1])
234+
ax_leg = fig_sb.add_subplot(gs[0, 2])
235+
ax_leg.axis("off")
228236

229237
def style_axes(ax, title_text, xlab, show_ylabel: bool):
230-
# Adding a bit of padding so bar labels don’t overlap with the title
231-
ax.set_title(title_text, fontsize=16, pad=20)
232-
ax.set_xlabel(xlab, fontsize=14, color="black")
238+
ax.set_title(title_text, fontsize=14, pad=15)
239+
ax.set_xlabel(xlab, fontsize=13, color="black")
233240
if show_ylabel:
234-
ax.set_ylabel("Flooded Building Counts", fontsize=14, color="black")
241+
ax.set_ylabel("Flooded Building Counts", fontsize=13, color="black")
235242
else:
236243
ax.set_ylabel("")
237244

238-
# Thicker black left/bottom spines
239245
for spine in ("left", "bottom"):
240246
ax.spines[spine].set_linewidth(1.5)
241247
ax.spines[spine].set_color("black")
242248

243249
sns.despine(ax=ax, right=True, top=True)
244-
ax.tick_params(axis="x", labelsize=12, colors="black")
245-
ax.tick_params(axis="y", labelsize=12, colors="black")
250+
ax.tick_params(axis="x", labelsize=11, colors="black")
251+
ax.tick_params(axis="y", labelsize=11, colors="black")
246252

247253
# Left panel
248-
ax0 = axes[0]
249-
sns.barplot(
250-
data=df_left, x="Category", y="Count", ax=ax0, palette=["#1c83eb", "#a4490e"]
251-
)
252-
style_axes(
253-
ax0, "Building Counts on Different FIMs", "Inundation Surface", show_ylabel=True
254-
)
254+
colors_left = ["#1c83eb", "#a4490e"]
255+
sns.barplot(data=df_left, x="Category", y="Count", ax=ax0, palette=colors_left)
256+
style_axes(ax0, "Building Counts on Different FIMs", "Inundation Surface", True)
255257
for c in ax0.containers:
256258
ax0.bar_label(
257-
c, fmt="%.0f", label_type="edge", padding=3, fontsize=14, color="black"
259+
c, fmt="%.0f", label_type="edge", padding=3, fontsize=12, color="black"
258260
)
259261

260262
# Right panel
261-
ax1 = axes[1]
262-
sns.barplot(
263-
data=df_right,
264-
x="Category",
265-
y="Count",
266-
ax=ax1,
267-
palette=["#ff5733", "#ffc300", "#28a745"],
268-
)
269-
style_axes(
270-
ax1, "Contingency Flooded Building Counts", "Category", show_ylabel=False
271-
)
263+
colors_right = ["#ff5733", "#ffc300", "#28a745"]
264+
sns.barplot(data=df_right, x="Category", y="Count", ax=ax1, palette=colors_right)
265+
style_axes(ax1, "Contingency Flooded Building Counts", "Category", False)
272266
for c in ax1.containers:
273267
ax1.bar_label(
274-
c, fmt="%.0f", label_type="edge", padding=3, fontsize=14, color="black"
268+
c, fmt="%.0f", label_type="edge", padding=3, fontsize=12, color="black"
275269
)
276270

271+
# Combined legend
272+
all_labels = ["Candidate", "Benchmark"] + third_raster_labels
273+
all_colors = colors_left + colors_right
274+
legend_handles = [
275+
plt.Line2D(
276+
[0],
277+
[0],
278+
marker="s",
279+
color="w",
280+
markerfacecolor=all_colors[i],
281+
markersize=12,
282+
label=f"{all_labels[i]} ({percentages[all_labels[i]]:.2f}%)",
283+
)
284+
for i in range(len(all_labels))
285+
]
286+
ax_leg.legend(handles=legend_handles, fontsize=12, loc="center left", frameon=True)
277287
plot_dir = os.path.join(save_dir, "FinalPlots")
278288
os.makedirs(plot_dir, exist_ok=True)
279289
output_path = os.path.join(plot_dir, f"BuildingCounts_{basename}.png")

tests/test_evaluationfim.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
Main_dir = (
55
# "../docs/sampledata"
6-
"/Users/supath/Downloads/MSResearch/FIMpef/fimpef/docs/sampledata"
76
)
87
PWD_dir = "./path/to/PWB"
98
output_dir = (
109
# "./path/to/output" # This is the output directory where the results will be saved
11-
"/Users/supath/Downloads/MSResearch/FIMpef/fimpef/docs/output"
1210
)
1311
target_crs = "EPSG:5070" # Target CRS for reprojecting the FIMs, need to be in EPSG code of Projected CRS
1412
target_resolution = 10 # This will be in meters, if it passes the FIMS will be resampled to this resolution else, it will find the coarser resolution among all FIMS for this case and use that to resample!
@@ -31,7 +29,7 @@
3129
def test_evaluation_framework():
3230
# Run the evaluation
3331
# It has the Permanent Water Bodies (PWB) dataset as default for United States
34-
fe.EvaluateFIM(Main_dir, method_name, output_dir)
32+
# fe.EvaluateFIM(Main_dir, method_name, output_dir)
3533

3634
# OR, If the Evaluation Study Area is outside the US or, user has their own PWB dataset
3735
# fe.EvaluateFIM(Main_dir, method_name, output_dir)
@@ -40,10 +38,10 @@ def test_evaluation_framework():
4038
# fe.EvaluateFIM(Main_dir, method_name, output_dir, target_crs=target_crs, shapefile_dir = AOI, target_resolution=target_resolution)
4139

4240
# # Once the FIM evaluation is done, print the contingency map
43-
fe.PrintContingencyMap(Main_dir, method_name, output_dir)
41+
# fe.PrintContingencyMap(Main_dir, method_name, output_dir)
4442

4543
# # Plot the evaluation metrics after the FIM evaluation
46-
fe.PlotEvaluationMetrics(Main_dir, method_name, output_dir)
44+
# fe.PlotEvaluationMetrics(Main_dir, method_name, output_dir)
4745

4846
# FIM Evaluation with Building Footprint (by default, it uses the Microsoft Building Footprint dataset)
4947
fe.EvaluationWithBuildingFootprint(

0 commit comments

Comments
 (0)