thornate
thornate

Reputation: 5130

Matplotlib x-axis only show actual values as labels

The data that I use for my matplotlib plots are spread unevenly around the x-axis. In the example below, for instance, the x-axis values are [0.001, 0.0033, 0.0066, 0.01, 0.033, 0.066, 0.1, 0.33]. Is it possible to get the x-axis to only draw tickers and labels at those specific values, rather than show the even range between 0 and 0.35?

Example plot

Upvotes: 4

Views: 3924

Answers (1)

BrenBarn
BrenBarn

Reputation: 251365

Assuming you're using the pyplot interface, you can use the pyplot.xticks function to set the x ticks to anything you like. So you can just do pyplot.xticks([0.001, 0.0033, 0.0066, 0.01, 0.033, 0.066, 0.1, 0.33]).

Upvotes: 2

Related Questions