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.

1 Answer 1

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?
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.