'How to scale x-axis in matplotlib with unequal gaps

I have to following table:

enter link description here

and I create the following graph with this code:

code:

plt.plot(new[201], label='201')
plt.genend()
plt.show()

graph:

enter link description here

how can I scale the x-axis NOT to be with equal gaps?

for example, if I use the same data in excel I get this graph:

enter link description here

so how can I make the graph in python to be like in excel ?



Solution 1:[1]

You seem to have your data as strings. Most likely the x-axis is occupied by string values. You have not provided the data, so I have no idea what new[201] looks like. However, I guess all you need is to cast it to float with something like:

new[201].astype(np.float)

Of course, this is for numpy array. In case your data have a different format, check the specific way to cast it from string to float.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ruli