Search code examples
pythonmatplotlibplotcumulative-frequency

Matplotlib: Avoid congestion in X axis


I'm using this code to plot a cumulative frequency plot:

lot = ocum.plot(x='index', y='cdf', yticks=np.arange(0.0, 1.05, 0.1))

plot.set_xlabel("Data usage")`
plot.set_ylabel("CDF")

fig = plot.get_figure()
fig.savefig("overall.png")

How it appears as follows and is very crowded around the initial part. This is due to my data spread. How can I make it more clear? (uploading to postimg because I don't have enough reputation points)

http://postimg.org/image/ii5z4czld/


Solution

  • I hope that I understood what you want: give more space to the visualization of the "CDF" development for smaller "data usage" values, right? Typically, you would achieve this by changing your X axis scale from linear to logarithmic. Head over to Plot logarithmic axes with matplotlib in python for seeing different ways to achieve that. The simplest might be, in your case, to replace plot() with semilogx().