Plot a list of tuples on x axis

Natasha

I've data like the following

x = [(1,0), (0, 1), (2, 1), (3, 1)]
y = [1, 4, 8.5, 17.5]

and I would like to plot in the following way

enter image description here

But matplotlib considers x as a 2 column vector so the y data is plotted twice. Suggestions on how to generate a plot in the above-mentioned format will be really helpful.

rftr

You can also convert the tuples to strings and plot a categorical scatter:

plt.scatter([str(i) for i in x], y)

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related