How to make xticks evenly spaced, despite their value?

I am trying to create a graph with the X axis being a geometric sequence, while the y axis is a number from 0.0 to 1.0. My code is as follows:

form matplotlib import pyplot as plt
plt.xticks(X)
plt.plot(X,Y)
plt.show()

which generates such a graph:

My plot

As you can see, I explicitly check the x-axis with those related to the geometric sequence.

My question is: is it possible to make x-ticks evenly spaced, despite their importance, since the initial terms of the sequence are small and filled together. I kind of like a logarithmic scale that would be ideal if it were to deal with the powers of the base, but not for the geometric sequence, as is the case here.

+4
1

, "" , . :

n = 12
a = np.arange(n)
x = 2**a
y = np.random.rand(n)

fig = plt.figure(1, figsize=(7,7))
ax1  = fig.add_subplot(211)
ax2  = fig.add_subplot(212)

ax1.plot(x,y)
ax1.xaxis.set_ticks(x)

ax2.plot(a, y) #we plot y as a function of a, which parametrizes x
ax2.xaxis.set_ticks(a) #set the ticks to be a
ax2.xaxis.set_ticklabels(x) # change the ticks' names to x

:

enter image description here

+4

Source: https://habr.com/ru/post/1654869/


All Articles