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:
Asked: 2023-05-05 13:38:10 +0000
Seen: 14 times
Last updated: May 05 '23