How to create a customized dimension in linespace

Viewed 25
X_new = np.linspace(1, len(cumsum), num=len(cumsum)).reshape(-1,1)
plt.ylabel('Explained Variance')
plt.xlabel('Dimensions')
plt.plot(X_new, cumsum, 'b-')

The above code gives a graph with x -axis starting from 0,100,200,300...800. But I want to shows X axis label as 0,50,100,150,200,250.....800. How do i do that. I tried with retstep =True and step =50 but could not obtain the desired label in X-axis with np.linespace()

1 Answers

You can try using the plt.xticks() method:

plt.xticks(np.arange(0, 8001, 50))
Related