2

Now I just simply use plt.plot(x,y1,'b.-') to plot a figure, but it turns out so many data are displayed between 0 to 10 on the x axis, so I want to set x axis like this 0,1,5,10,100,1000,100000

thus, the massive data between 0 to 10 can be more spread out.

How can I do it in Python, I am using Matplotlib

2 Answers 2

4

0,1,5,10,100,1000,100000?

If you can live with (0.01, 0.1,), 1, 10, 100, 1000, 10000, 100000,… - then change the xscale to log:

plt.xscale('log')
Sign up to request clarification or add additional context in comments.

Comments

2

See the accepted answer to the question How do I convert (or scale) axis values and redefine the tick frequency in matplotlib? Essentially, the matplotlib.pyplot.xticks command can be used to control to location and labels of the tick marks.

However, your data will still be plotted on a linear scale, so this won't strecth out the data between 0 and 10. You will need to use a different axis scaling to do this, using, for example, set_xscale.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.