Skip to content

Commit 57e50ef

Browse files
author
shanedsnyder
authored
Merge pull request #883 from tylerjereddy/treddy_issue_881
MAINT: I/O cost label spacing
2 parents 1fa7919 + 93d5c3a commit 57e50ef

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

darshan-util/pydarshan/darshan/experimental/plots/plot_io_cost.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ def plot_io_cost(report: darshan.DarshanReport) -> Any:
173173
ax_raw.set_ylabel("Runtime (s)")
174174
handles, labels = ax_raw.get_legend_handles_labels()
175175
ax_norm.legend(handles[::-1], labels[::-1], loc="upper left", bbox_to_anchor=(1.22, 1.02))
176+
# rotate the xticklabels so they don't overlap
177+
for ax in [ax_raw, ax_norm]:
178+
for label in ax.get_xticklabels():
179+
label.set_rotation(90)
176180
# adjust the figure to reduce white space
177181
io_cost_fig.subplots_adjust(right=0.59)
178182
io_cost_fig.tight_layout()

darshan-util/pydarshan/darshan/tests/test_plot_io_cost.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
from packaging import version
12
import pytest
23
import numpy as np
34
from numpy.testing import assert_allclose, assert_array_equal
45
import pandas as pd
56
from pandas.testing import assert_frame_equal, assert_series_equal
7+
import matplotlib
68

79
import darshan
810
from darshan.log_utils import get_log_path
@@ -272,3 +274,44 @@ def test_combine_hdf5_modules(input_df, expected_df):
272274

273275
# check actual and expected dataframes are identical
274276
assert_frame_equal(actual_df, expected_df)
277+
278+
279+
@pytest.mark.parametrize(
280+
"logname, expected_xticks, expected_xlabels", [
281+
(
282+
"shane_ior-PNETCDF_id438100-438100_11-9-41525-10280033558448664385_1.darshan",
283+
range(4),
284+
["POSIX", "MPIIO", "PNETCDF", "STDIO"]
285+
),
286+
(
287+
"imbalanced-io.darshan",
288+
range(3),
289+
["POSIX", "MPIIO", "STDIO"]
290+
),
291+
],
292+
)
293+
def test_plot_io_cost_x_ticks_and_labels(logname,
294+
expected_xticks,
295+
expected_xlabels):
296+
# check the x-axis tick marks are at the appropriate
297+
# locations and the labels are as expected
298+
299+
logpath = get_log_path(logname)
300+
with darshan.DarshanReport(logpath) as report:
301+
fig = plot_io_cost(report=report)
302+
for i, ax in enumerate(fig.axes):
303+
if i > 0 and version.parse(matplotlib.__version__) < version.parse("3.6.0"):
304+
# the second (invisible/twinned) axis is effectively
305+
# empty in older matplotlib versions
306+
continue
307+
# there are only 2 axes, the first being the "raw" data
308+
# and the second being the normalized data (percent)
309+
actual_xticks = ax.get_xticks()
310+
xticklabels = ax.get_xticklabels()
311+
actual_xticklabels = [tl.get_text() for tl in xticklabels]
312+
assert_allclose(actual_xticks, expected_xticks)
313+
assert_array_equal(actual_xticklabels, expected_xlabels)
314+
# regression test for gh-881
315+
expected_rotations = 90
316+
x_rotations = [tl.get_rotation() for tl in xticklabels]
317+
assert_allclose(x_rotations, expected_rotations)

0 commit comments

Comments
 (0)