How to plot a list of tuples in the python using matplotlib module? List of the tuples
[(155, 16.84749748246271), (158, 13.618280538390644), (38, 13.103707537648402), (53, 10.157244261797375), (156, 6.779897254994966), (119, 6.27045632052444), (159, 4.3453112093858275), (161, 4.028984416275573), (32, 4.026263736663865), (118, 3.437058351914913)]
In tuples first values represents the reaction number and second values represent sensitivity.
How about:
import matplotlib.pyplot as plt
plt.plot([(155, 16.84749748246271), (158, 13.618280538390644), (38, 13.103707537648402), (53, 10.157244261797375), (156, 6.779897254994966), (119, 6.27045632052444), (159, 4.3453112093858275), (161, 4.028984416275573), (32, 4.026263736663865), (118, 3.437058351914913)])
plt.show()
I assume you want reaction number on the x axis and sensitivity on the y axis. In this case you have to transpose the list:
xs = [x for x, y in data]
ys = [y for x, y in data]
plt.plot(xs, ys)
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With