Graph X-Axis from CSV File with Python

  • Context: Python 
  • Thread starter Thread starter chipotleaway
  • Start date Start date
  • Tags Tags
    Python
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 3K views
chipotleaway
Messages
174
Reaction score
0
How do if you have a .csv file with 3 columns (independent, dependent, uncertainty in dependent variable), how do you make a graph so that the independent variable is the x-axis and the dependent is the y axis?

All I've done is
Code:
pylab.plot(data,"ko")
pylab.show()

The graph I get seems to have plotted the independent variable as the dependent...as well as the other two columns
 
Physics news on Phys.org
hhhmmm...passing a single 2D array may be causing plot to plot all columns against the row index...try passing the individual columns explicitly, something like plot(data[0],data[1],'ko')
 
  • Like
Likes   Reactions: 1 person
Thanks, got it now. Looks like it's plotting everything correctly