LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-27-2016, 05:36 PM   #1
usamaAkhtar
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Rep: Reputation: Disabled
plot using .dat file


hi!

i need help to plot certain values which i have saved in a .dat file.
here is the screenshot of .dat file.. please help!!
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	27
Size:	10.0 KB
ID:	23110  
 
Old 09-27-2016, 07:09 PM   #2
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,630

Rep: Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529
If you just want to remove the text from the file to leave the numbers:
Code:
sed 's/[^ ]*=//g' file.dat
 
Old 09-27-2016, 09:02 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,189

Rep: Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507
also WHAT software are you using ?
and what language is it in ?
python ?
perl ?
m( matlab) ?
FORTRAN ?

or are you using a spreadsheet program ?

or just the terminal only and bash scripting it ?

i could go on GUESSING!!!!!!

but you need to fill in the blanks
 
Old 09-27-2016, 09:32 PM   #4
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 2,320

Rep: Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947Reputation: 947
Feed me! Feed me DATA!

Agree with above, you need to feed us enough information for us to understand what you are going to need.

If my program returned a data file like that, with no time stamp or sequence number, I would be ashamed.
GNUPLOT could be used to extract and plot data for that format, but it would be slightly ugly. There is no way to reorder the data and reliably maintain any interesting kind of relationships, so the current order must be preserved.

From whence came this data?
 
Old 09-27-2016, 10:42 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,189

Rep: Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507
for a output like you posted
Libreoffice's Calc will do

import it as a CSV and make a graph
 
Old 09-28-2016, 03:52 AM   #6
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 494

Rep: Reputation: 233Reputation: 233Reputation: 233
Hi,

If there were only numbers in two distinct columns, it could have been plotted easily with gnuplot at the command line.

Provided you have gnuplot, you could do:
Code:
$ gnuplot
gnuplot> plot "FILE.dat" with line
Or, of course, if you have an office suit, you could use a spreadsheet software to do the plot.
 
Old 09-28-2016, 11:20 AM   #7
usamaAkhtar
LQ Newbie
 
Registered: Sep 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
@ john VV

I am using geany as IDE. language is C. the values are of four different channels from MCP3208 which give them to pi and pi apply certain features like MAV and RMS etc to these values which are saved in .dat/.csv file. i have to plot them seperately but as they are in same column so gnuplot is taking all of them plotting a single graph which of no use... i have to chnage them into four diffrent columns. i have tried changing loops but vain....
 
Old 09-28-2016, 12:12 PM   #8
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,189

Rep: Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507Reputation: 2507
then use a spreadsheet

calc ( excel) can do many things -- even play space invaders using the cells
 
Old 10-01-2016, 05:32 AM   #9
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 173

Rep: Reputation: 59
There is a major problem with

sed 's/[^ ]*=//g' file.dat

in that it will remove the space between the columns creating one number for each line. For ex:

channels=1 Voltage=1.82
channels=2 Voltage=0.34

would become

11.82
20.34

You would need to either keep the space or replace it with a comma.

sed -e 's/^*=//g' -e 's/[ ]*=/,/g' file.dat

The above would work if my sed syntax is correct. The first rule matches the newline and removes everything. The second matches the space between columns and replaces it with a comma. You should get

1,1.82
2,0.34
 
Old 10-01-2016, 05:53 AM   #10
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,630

Rep: Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529Reputation: 1529
From 'info sed'
Quote:
`[LIST]'
`[^LIST]'
Matches any single character in LIST: for example, `[aeiou]'
matches all vowels. A list may include sequences like
`CHAR1-CHAR2', which matches any character between (inclusive)
CHAR1 and CHAR2.

A leading `^' reverses the meaning of LIST, so that it matches any
single character _not_ in LIST. To include `]' in the list, make
it the first character (after the `^' if needed), to include `-'
in the list, make it the first or last; to include `^' put it
after the first character.
so 's/[^ ]*=//g' matches the non-space characters and the '=', and replaces them with nothing, for every occurrence in the line. The space character is preserved, so no major problem.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the frequency plot spectrum of a wav file? vvn2023 Linux - Software 9 06-13-2016 06:02 AM
plot trace file into a graph tootz Linux - Software 14 04-26-2012 03:07 AM
software to plot .dat file in linux platform s_hy Programming 10 03-14-2012 03:09 AM
[SOLVED] How to use .plot file to draw a graph? haiying7 Linux - Newbie 4 12-06-2011 01:20 AM
.plot file printing Pier Linux - General 0 12-18-2005 03:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration