How to assign equal scaling on the x-axis in Matplotlib?

Viewed 3158

What I currently have is this:

x = [3.0, 4.0, 5.0, 5.0, 6.0, 7.0, 9.0, 9.0, 9.0, 11.0]
y = [6.0, 5.0, 4.0, 2.5, 3.0, 2.0, 1.0, 2.0, 2.5, 2.5]

Which produces the following graph:

enter image description here

What I'd like is to have equal scaling on my axis. Therefore, instead of having such a large gap between 7 and 9 and also 9 and 11, it'd be a space equal like all others. It's look like this:

enter image description here

To eliminate the 8 and the 10 from the graph I used ticks. Here is the relevant code:

ax=fig.add_subplot(111, ylabel="speed")
ax.plot(x, y, 'bo')
ax.set_xticks(x) 

None of the examples on the matplotlib page have anything that I desire. I've been looking through the documentation, but everything 'scaling' related doesn't do what I want it to do.

Can this be done?

1 Answers
Related