By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

How to plot simple graph?

P: 30
hi,

i'm new to python. i want to read from a text file and i want to plot a scatterplot. i want to plot lane as X-axis, EyVt and EyHt as Y-axis. i'm using Python 2.5 and Win XP.
i have a sample code but i need help on how to get python start reading column Lane, EyVt and EyHt. Pls help. tq

eg of text file content:
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1

+++++++++++++++++++++++++++++++++++++++++++++
Port Chnl Lane EyVt EyHt
+++++++++++++++++++++++++++++++++++++++++++++
0 1 1 75 55
0 1 2 10 35
0 1 3 25 35
0 1 4 35 25
0 1 5 10 20
+++++++++++++++++++++++++++++++++++++++++++++
Time: 20s


Expand|Select|Wrap|Line Numbers
  1. import numpy as np
  2. import pylab as pl
  3.  
  4. data=np.loadtxt('sampledata.txt')
  5.  
  6. pl.plot(data[:,0],data[:,1],'ro')
  7. pl.xlabel('x')
  8. pl.ylabel('y')
  9. pl.xlim(0.0,10.)
  10.  
  11. pl.show()
  12.  
Jan 22 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.