Fine control of the axes — where they start and stop, which ticks show, how they're labelled — is often the difference between a chart that misleads and one that's honest and clear.
Axis limits
ax.set_xlim(0, 100)ax.set_ylim(bottom=0) # force the y-axis to start at zeroax.set_yscale("log") # log scale for wide-ranging data
Ticks & labels
ax.set_xticks([0, 25, 50, 75, 100])ax.set_xticklabels(["Q1", "Q2", "Q3", "Q4", "Q5"], rotation=45)ax.tick_params(axis="y", labelsize=9)
Key takeaways
- 01set_xlim/set_ylim control the visible range; set_yscale("log") for wide ranges.
- 02set_xticks/set_xticklabels place and label ticks explicitly.
- 03Rotate long tick labels to prevent overlap.
- 04Start bar/comparison y-axes at zero — a truncated axis misleads.
