LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 02-08-2015, 02:45 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Rep: Reputation: Disabled
How to color different lines in gnuplot


Hi there. My environment is Ubuntu 12.04 OS. I have an example of the files I create with gfortran and gnuplot. The gnuplot draws this picture from a data file with 2D Cartesian coordinates. It is perpective projection. I need to color some parts of the plot (various lines) in different colors because some other details must also be drawn and I feel that the resulting network will be confusing. Gnuplot user manuals treat this subject but only in conjunction with lines drawn through a formula like sin(x), etc. I don't have that. All I have is columns of floating point numbers. Is there way I can draw lines of different color with gnuplot 4.6?

Thanks, - A.
Attached Thumbnails
Click image for larger version

Name:	MyscreenImage2.png
Views:	19
Size:	23.1 KB
ID:	17545  
 
Old 02-08-2015, 03:09 PM   #2
floppy_stuttgart
Member
 
Registered: Nov 2010
Location: Stuttgart, Germany
Distribution: Debian like
Posts: 710
Blog Entries: 2

Rep: Reputation: 68
http://www.gnuplot.info/docs_4.6/gnuplot.pdf
page 231?
 
Old 02-08-2015, 04:32 PM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Thanks, however it does not seem to be what I need. I have read it multiple times and all I could figure out was that with multiplot I can draw a few separate plots (with individual XY coordinate systems) on one plot or one piece of paper.

Last edited by AlexBB; 02-09-2015 at 10:53 AM.
 
Old 02-08-2015, 09:14 PM   #4
flshope
Member
 
Registered: Jul 2009
Location: Murfreesboro TN (United States)
Distribution: Ubuntu 16.04.1, 14.04.4, Debian 8.6
Posts: 120
Blog Entries: 32

Rep: Reputation: 26
The 'every' option on the plot command

The 'every' option on the plot command can be used to pick out specific records and record blocks on the data file and plot them with specific colors (by specifying the 'lt' value). The interactive help facility in gnuplot explains the 'every' option.
 
Old 02-09-2015, 08:06 PM   #5
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
flshope, thank you. Perhaps it will work. Will try my best.
 
Old 02-10-2015, 09:16 PM   #6
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
The index keyword seems to be doing the trick. A sample:

Quote:
plot [-5.5:-2][-3:1] "perspectProj.dat" with lines lt 1, \
"perspectProj.dat" index 35 with lines lc rgb "cyan"
Thanks, The problem's solved. Big deal for me.

Last edited by AlexBB; 02-11-2015 at 09:34 PM.
 
1 members found this post helpful.
Old 02-11-2015, 07:23 AM   #7
flshope
Member
 
Registered: Jul 2009
Location: Murfreesboro TN (United States)
Distribution: Ubuntu 16.04.1, 14.04.4, Debian 8.6
Posts: 120
Blog Entries: 32

Rep: Reputation: 26
I hadn't used 'index' before this. Must look into it. Thanks for the feedback.
 
Old 02-11-2015, 11:07 AM   #8
AlexBB
Member
 
Registered: Mar 2014
Posts: 435

Original Poster
Rep: Reputation: Disabled
Yep, it turned out to be a solution in my case, although I suspect that every can also be worked out. This is what I did. I have (it turned out) 35 blocks of floating point numbers, printed into a data file in a two column arrangement. Two blank lines are allowed between two adjacent blocks. I changed the source code minimally to also print out a 'block number" at the beginning of each block like this:

Quote:
# block: N
where N stands for a number: 0,1,2...

thus I knew which block I needed to use to change the color. There are many other tricks in gnuplot which I still do not understand how to use, hopefully they will come later. In principle you can almost color every point of a line with a different color if you wish but for that you have to print a separate column with the color information.

Last edited by AlexBB; 02-11-2015 at 11:12 AM.
 
1 members found this post helpful.
  


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 can I print lines to the console in a certain color? abefroman Programming 5 10-30-2013 05:23 PM
assigning color to numbers and plotting in GNUPLOT pravas Linux - Newbie 1 12-08-2011 01:05 PM
Drawing vertical AND horizonal lines in a single gnuplot plot Daravon Linux - Software 0 07-22-2009 05:22 PM
Mandriva 2009 starts installation and then monitor starts rolling showing color lines HubertHickey Linux - Newbie 6 12-18-2008 01:24 AM


All times are GMT -5. The time now is 08:26 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