0

I have a list like : [[5, 1.1066720079718957], [10, 1.075297753414681], [15, 1.0958222358382397], [20, 1.092081009894558], [25, 1.0968130408510393]]

I am trying to plot using matplotlib where values 5,10,15,20,25 are on x-axis where as 1.1066720079718957,1.075297753414681,1.0958222358382397,1.092081009894558,1.0968130408510393 on y-axis

I am not able to do it in few lines.

Raj
  • 93
  • 8

1 Answers1

1
import matplotlib.pyplot as plt

data = [[5, 1.1066720079718957], [10, 1.075297753414681], [15, 1.0958222358382397], [20, 1.092081009894558], [25, 1.0968130408510393]]

plt.plot([i[0] for i in data], [i[1] for i in data])
plt.show()

Maybe these two links will also useful if you are working with nested lists and list comprehensions

  1. Nested lists python
  2. What does "list comprehension" mean? How does it work and how can I use it?
krm
  • 528
  • 4
  • 12