Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way to achieve uneven tick intervals on the Y-axis is to specify the tick locations and labels manually. This can be done using the yticks() function in pyplot (if using Matplotlib) or the scale_y_continuous() function in ggplot2 (if using R).

For example, in Matplotlib, the following code sets tick locations at [0, 10, 20, 40, 60], and corresponding tick labels as ["0", "10-20", "20-40", "40-60", ">60"]:

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4, 5], [5, 15, 25, 45, 70])
plt.yticks([0, 10, 20, 40, 60], ["0", "10-20", "20-40", "40-60", ">60"])
plt.show()

This produces a graph with tick intervals that are uneven:

uneven-tick-intervals