viz: always rotate x-axis labels 45° to prevent overlap (keep tick density)
All checks were successful
Generate banlist history graph / build (push) Successful in 7s
All checks were successful
Generate banlist history graph / build (push) Successful in 7s
This commit is contained in:
parent
744be92f69
commit
f8b4611c06
1 changed files with 8 additions and 3 deletions
|
@ -112,16 +112,21 @@ def write_chart(snaps: List[Snapshot], image_path: str) -> None:
|
|||
ax.set_ylabel("IP count")
|
||||
ax.grid(True, linestyle=":", linewidth=0.5)
|
||||
|
||||
# Reduce x-axis label crowding
|
||||
# Reduce x-axis label crowding; keep ticks but rotate labels for readability
|
||||
try:
|
||||
locator = mdates.AutoDateLocator(minticks=4, maxticks=8)
|
||||
formatter = mdates.ConciseDateFormatter(locator)
|
||||
ax.xaxis.set_major_locator(locator)
|
||||
ax.xaxis.set_major_formatter(formatter)
|
||||
except Exception:
|
||||
# Fallback: rotate labels if ConciseDateFormatter isn't available
|
||||
pass
|
||||
|
||||
# Always rotate for readability regardless of formatter availability
|
||||
try:
|
||||
fig.autofmt_xdate(rotation=45, ha="right")
|
||||
except Exception:
|
||||
for label in ax.get_xticklabels():
|
||||
label.set_rotation(30)
|
||||
label.set_rotation(45)
|
||||
label.set_horizontalalignment("right")
|
||||
|
||||
# Add slight horizontal margins to prevent clipping at edges
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue