Reputation: 150
I'm trying to plot the percentile.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import mlab
d = np.array([pow(i,5) for i in range(1,1000)])
# Percentile values
p = np.array([10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0])
perc = mlab.prctile(d, p=p)
plt.plot(d)
# Place red dots on the percentiles
plt.plot((len(d)-1) * p/100., perc, 'ro')
# Set tick locations and labels
plt.xticks((len(d)-1) * p/100., map(str, p))
plt.show()
But actually I prefer only shows the graph from 90 to 100 So I modified the p in my code
p = np.array([99.0, 99.1, 99.2, 99.3, 99.4, 99.5, 99.6, 99.7, 99.8, 99.9, 100.0])
And now all the x index squeeze to the right side. And the plot still shows all data.
Upvotes: 0
Views: 953
Reputation: 11
You can set the x range of your plot with:
plt.xlim(90, 100)
If this is what you want.
see xlim docu
Upvotes: 1