0

I have the following plot:

enter image description here

How can I increase the space among values in X axis with matplotlib?

Thanks!

giupardeb
  • 791
  • 1
  • 5
  • 13
  • 3
    Can you share a code snippet that we can reproduce the plot? – David Feb 27 '21 at 15:04
  • https://stackoverflow.com/questions/44863375/how-to-change-spacing-between-ticks-in-matplotlib – thethiny Feb 27 '21 at 15:10
  • Does this answer your question? [How to change spacing between ticks in matplotlib?](https://stackoverflow.com/questions/44863375/how-to-change-spacing-between-ticks-in-matplotlib) – Polkaguy6000 Feb 27 '21 at 16:02

1 Answers1

0

You can set a log scale and invert the x-axis:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import ScalarFormatter

x = [round(28800 * 2 ** (-i)) for i in range(10)]
y = np.random.randint(0, 80, len(x))
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xscale('log')
ax.set_xticks(x)
ax.xaxis.set_major_formatter(ScalarFormatter())
ax.invert_xaxis()
plt.show()

example plot

JohanC
  • 71,591
  • 8
  • 33
  • 66