Skip to content

Commit f26fdbb

Browse files
committed
Made review changes
1 parent abff7c7 commit f26fdbb

File tree

2 files changed

+61
-10
lines changed

2 files changed

+61
-10
lines changed

scripts/3-report/smithsonian_report.py

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def plot_totals_by_top10_units(args):
150150
data.sort_values(data_label, ascending=True, inplace=True)
151151
data = data.tail(10)
152152
average_unit = data["Total_objects"].mean()
153-
title = "Top 10 Units"
153+
title = "Totals by 10 Units"
154154
plt = plot.combined_plot(
155155
args=args,
156156
data=data,
@@ -233,11 +233,11 @@ def plot_totals_by_lowest10_units(args):
233233
)
234234

235235

236-
def plot_totals_by_records(args):
236+
def plot_totals_by_top10_unit_records(args):
237237
"""
238-
Create plots showing totals by records
238+
Create plots showing breakdown of CC0 records by top 10 units
239239
"""
240-
LOGGER.info(plot_totals_by_records.__doc__.strip())
240+
LOGGER.info(plot_totals_by_top10_unit_records.__doc__.strip())
241241
file_path = shared.path_join(
242242
PATHS["data_2-process"],
243243
"smithsonian_totals_by_records.csv",
@@ -253,7 +253,7 @@ def plot_totals_by_records(args):
253253
data = shared.open_data_file(LOGGER, file_path, index_col=name_label)
254254
data.sort_values(data_label, ascending=True, inplace=True)
255255
data = data.tail(10)
256-
title = "Totals by records"
256+
title = "Breakdown of CC0 records by top 10 units"
257257
plt = plot.stacked_barh_plot(
258258
args=args,
259259
data=data,
@@ -262,7 +262,7 @@ def plot_totals_by_records(args):
262262
stack_labels=stack_labels,
263263
)
264264
image_path = shared.path_join(
265-
PATHS["data_phase"], "smithsonian_by_records.png"
265+
PATHS["data_phase"], "smithsonian_by_top10_unit_records.png"
266266
)
267267
LOGGER.info(f"image file: {image_path.replace(PATHS['repo'], '.')}")
268268
if args.enable_save:
@@ -283,6 +283,56 @@ def plot_totals_by_records(args):
283283
)
284284

285285

286+
def plot_totals_by_lowest10_unit_records(args):
287+
"""
288+
Create plots showing breakdown of CC0 records by lowest 10 units
289+
"""
290+
LOGGER.info(plot_totals_by_lowest10_unit_records.__doc__.strip())
291+
file_path = shared.path_join(
292+
PATHS["data_2-process"],
293+
"smithsonian_totals_by_records.csv",
294+
)
295+
LOGGER.info(f"data file: {file_path.replace(PATHS['repo'], '.')}")
296+
name_label = "Unit_name"
297+
data_label = "Total_objects"
298+
stack_labels = [
299+
"CC0_without_media_percentage",
300+
"CC0_with_media_percentage",
301+
"Others_percentage",
302+
]
303+
data = shared.open_data_file(LOGGER, file_path, index_col=name_label)
304+
data.sort_values(data_label, ascending=True, inplace=True)
305+
data = data.head(10)
306+
title = "Breakdown of CC0 records by lowest 10 units"
307+
plt = plot.stacked_barh_plot(
308+
args=args,
309+
data=data,
310+
title=title,
311+
name_label=name_label,
312+
stack_labels=stack_labels,
313+
)
314+
image_path = shared.path_join(
315+
PATHS["data_phase"], "smithsonian_by_lowest10_unit_records.png"
316+
)
317+
LOGGER.info(f"image file: {image_path.replace(PATHS['repo'], '.')}")
318+
if args.enable_save:
319+
# Create the directory if it does not exist
320+
os.makedirs(PATHS["data_phase"], exist_ok=True)
321+
plt.savefig(image_path)
322+
323+
shared.update_readme(
324+
args,
325+
SECTION_FILE,
326+
SECTION_TITLE,
327+
title,
328+
image_path,
329+
"Plots showing totals by CC0 records. This is the"
330+
" lowest 10 units with a breakdown of CC0 records"
331+
" without media, CC0 records with media and records"
332+
" that are not associated with CC0.",
333+
)
334+
335+
286336
def main():
287337
args = parse_arguments()
288338
shared.paths_log(LOGGER, PATHS)
@@ -294,7 +344,8 @@ def main():
294344
smithsonian_intro(args)
295345
plot_totals_by_top10_units(args)
296346
plot_totals_by_lowest10_units(args)
297-
plot_totals_by_records(args)
347+
plot_totals_by_top10_unit_records(args)
348+
plot_totals_by_lowest10_unit_records(args)
298349

299350
# Add and commit changes
300351
args = shared.git_add_and_commit(

scripts/plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def combined_plot(
7373
height = 2.5
7474

7575
fig, (ax1, ax2) = plt.subplots(
76-
1, 2, figsize=(8, height), width_ratios=(2, 1), layout="constrained"
76+
1, 2, figsize=(10, height), width_ratios=(2, 1), layout="constrained"
7777
)
7878
colors = colormaps["tab10"].colors
7979

@@ -188,7 +188,7 @@ def stacked_barh_plot(
188188
plt.rcParams.update({"font.family": "monospace", "figure.dpi": 300})
189189

190190
height = max(2.5, 1 + len(data) * 0.5)
191-
fig, ax = plt.subplots(figsize=(8, height), layout="constrained")
191+
fig, ax = plt.subplots(figsize=(10, height), layout="constrained")
192192

193193
colors = colormaps["tab10"].colors
194194
left = [0] * len(data)
@@ -222,7 +222,7 @@ def stacked_barh_plot(
222222
title="Type",
223223
fontsize="x-small",
224224
title_fontsize="x-small",
225-
loc="upper right",
225+
loc="upper left",
226226
bbox_to_anchor=(1.02, 1),
227227
)
228228

0 commit comments

Comments
 (0)