Oria Gruber
Oria Gruber

Reputation: 1533

pyplot strange output, plotting two simple lists as graph

I have two lists, one corresponds to x values and another corresponds to y values. So you can reproduce it, the lists are x = [1, 10, 50, 100, 250, 500, 750, 900, 950, 1000, 1500, 2000, 3500, 5000, 6500, 8000, 9000, 1000, 11000, 12000, 14000]

and y = [0.8980629181861878, 0.10853165966272355, 0.08126119875907897, 0.06252053439617157, 0.06377455067634583, 0.06653642201423646, 0.059822401523590085, 0.062289491295814514, 0.05231357836723328, 0.05339253479242325, 0.05086378312110901, 0.05312803852558136, 0.059300369888544084, 0.05587265187501907, 0.06438382065296173, 0.059782819837331774, 0.08129128956794739, 0.05339253479242325, 0.08861093366146088, 0.0757862297296524, 0.10072390681505203]

When I write

plt.plot(x, y, marker='D')
plt.xlabel("x")
plt.ylabel("y")
plt.show()

It outputs this image enter image description here

This is strange as I expect each diamond to be connected to only one other diamond, the one adjacent to him from the right as we look on x axis.

What am I doing wrong?

Upvotes: 0

Views: 37

Answers (1)

Simon Hostettler
Simon Hostettler

Reputation: 186

Your input is formatted wrong, x contains 1000 after 9000, it should be 10000. Pyplot plotted your values correctly.

Upvotes: 3

Related Questions