Re: gnuplot: plotting each point in different color
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 H.S. wrote on 2008-03-27 23:31: Well, I had already read that portion (in the online documentation though). But from gnuplot's documentation it appears that one should have read *all* the relevant documentation also to understand any portion of it. Textbooks do not have examples for no reason you see. I was looking for one here too. Well I've also had the experience, that gnuplot has a very steep learning curve and that it takes some time to 'learn the gnuplot way'. After all, the manual contains more than 200 densely written pages - no easy reading. On the other hand, gnuplot is so powerful that it is worth the struggle. My 2ct. Johannes -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH7J7tC1NzPRl9qEURAtvNAJkBZh+v4WfsYn6uhkMyPKb23T860QCeNlU1 wxx3at6kCqVqgWjS2yWO0dw= =/emQ -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
On Thu, Mar 27, 2008 at 21:56:10 -0400, H.S. wrote: Florian Kulzer wrote: One more thing worth mentioning is that the subroutine trick can also be used to loop over the columns of a dataset (using the column command), for example if you have a data file with one common x-axis and 100 y-datasets (columns) that you want plot in the same graph. (Or can the plot command do this automatically these days?) You might be looking for 'using'. Here is an example: gnuplot plot force.dat using 1:2 title 'Column', \ force.dat using 1:3 title 'Beam' If you have three cols in a force.dat file. That is indeed fine for three columns or ten, maybe twenty; my point was that it scales badly to, say, 1000 columns. There are of course other ways around this, like generating 1000 plot commands with your favorite scripting language and feeding them to gnuplot, or reformatting the data file to two columns with a 999-fold repeating x-axis, but these approaches do not seem any nicer to me than the subroutine-if-reread hack. -- Regards,| http://users.icfo.es/Florian.Kulzer Florian | -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
Florian Kulzer wrote: That is indeed fine for three columns or ten, maybe twenty; my point was that it scales badly to, say, 1000 columns. There are of course other ways around this, like generating 1000 plot commands with your favorite scripting language and feeding them to gnuplot, or reformatting the data file to two columns with a 999-fold repeating x-axis, but these approaches do not seem any nicer to me than the subroutine-if-reread hack. Ah, yes, I agree. For such a large number of columns, or if the number of columns is determined at run time of an experiment, that method is the way to go. BTW, thanks for pointing me to this reread command. I did some google search to find out some examples. Here is one similar to what you explained: http://opensource.cqu.edu.au/cgi-bin/info/info2html.cgi?(gnuplot)reread and this another one explains the reread command with some other examples: http://t16web.lanl.gov/Kawano/gnuplot/misc1-e.html http://www.cs.unc.edu/~jeffay/dirt/FAQ/gnuplot.html thanks, -HS -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
gnuplot: plotting each point in different color
Hi, I have tried Gnuplot mailing list and the newsgroup but didn't get the help I was looking for. So here my try there. Given a data file: # 3cols.dat # 0.28460.1857 1 0.82830.1330 2 0.33060.8348 3 0.79610.7968 4 # I want to plot the 2-D points given by first two columns in a color given by the their label in the last column. The color doesn't matter, only that points with a particular label are plotted with the same color. Here is what I have so far: set pm3d set palette rgb 33,13,10 set view map set cbrange [1:4] ssplot 3cols.dat with points palette pt 9 However, a knowledgeable soul at the Gnuplot mailing list has informed me that using pm3d is a bad idea (the above command spews out warnings about not enough isosamples) and I should use 'plot' command for this. But he did not follow that up with a little example. So, can anyone here give an example using the plot command for this purpose? This is on Debian testing, Gnuplot 4.2. thanks, -HS -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 H.S. wrote: Hi, I have tried Gnuplot mailing list and the newsgroup but didn't get the help I was looking for. So here my try there. Given a data file: # 3cols.dat # 0.28460.1857 1 0.82830.1330 2 0.33060.8348 3 0.79610.7968 4 # I want to plot the 2-D points given by first two columns in a color given by the their label in the last column. The color doesn't matter, only that points with a particular label are plotted with the same color. Here is what I have so far: set pm3d This is to plot 3d surfaces in a 2d representation. You only have two coordinates, ie a 2d plot. I did: set palette splot '3cols.dat' us 1:2:3 w p palette I don't know if that's what you want? set palette rgb 33,13,10 set view map set cbrange [1:4] ssplot 3cols.dat with points palette pt 9 However, a knowledgeable soul at the Gnuplot mailing list has informed me that using pm3d is a bad idea (the above command spews out warnings about not enough isosamples) and I should use 'plot' command for this. But he did not follow that up with a little example. The knowledgeable soul told you to read the manual. # aptitude install gnuplot-doc as ordinary user within a directory for personal documentation: $ cp /usr/share/doc/gnuplot-doc/gnuplot.ps.gz . $ gunzip gnuplot.ps.gz $ ps2pdf gnuplot.ps $ kpdf gnuplot.pdf You'll want to read pp. 64ff. (For me this is more convenient, but of course there are other ways to read the gzipped ps.) HTH, Johannes -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH7AWUC1NzPRl9qEURAptSAJwMwXfZuWztNuIivD9NC5XSNINiMQCfaSJS zIaHSeYYNo7vuXbsm0HTIUA= =5M62 -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
On Thu, Mar 27, 2008 at 15:52:58 -0400, H.S. wrote: Hi, I have tried Gnuplot mailing list and the newsgroup but didn't get the help I was looking for. So here my try there. Given a data file: # 3cols.dat # 0.28460.1857 1 0.82830.1330 2 0.33060.8348 3 0.79610.7968 4 # I want to plot the 2-D points given by first two columns in a color given by the their label in the last column. The color doesn't matter, only that points with a particular label are plotted with the same color. Here is what I have so far: set pm3d set palette rgb 33,13,10 set view map set cbrange [1:4] ssplot 3cols.dat with points palette pt 9 However, a knowledgeable soul at the Gnuplot mailing list has informed me that using pm3d is a bad idea (the above command spews out warnings about not enough isosamples) and I should use 'plot' command for this. But he did not follow that up with a little example. The gnuplot list is no match for the vast and mysterious powers of debian-user... So, can anyone here give an example using the plot command for this purpose? This is on Debian testing, Gnuplot 4.2. For a small number of colors something like this is may be acceptable: # START unset key set xrange [0:1] set yrange [0:1] set multiplot plot 3cols.dat using ($1):($3==1 ? $2 : 1/0) lt 1 plot 3cols.dat using ($1):($3==2 ? $2 : 1/0) lt 2 plot 3cols.dat using ($1):($3==3 ? $2 : 1/0) lt 3 plot 3cols.dat using ($1):($3==4 ? $2 : 1/0) lt 4 unset multiplot # END To scale this up sensibly for many more colors, put the plot command into a separate file that is called as a subroutine from the main program. In this subroutine you can use a counter variable for both the $3 comparison and the lt assignment. After the plot command you can increment the counter and use the if/reread trick (see the manual) to make sure that the subroutine is re-executed as many times as is necessary to loop over all the colors. -- Regards,| http://users.icfo.es/Florian.Kulzer Florian | -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
Johannes Wiedersich wrote: I did: set palette splot '3cols.dat' us 1:2:3 w p palette I don't know if that's what you want? Thanks, that worked. The knowledgeable soul told you to read the manual. Yes, I know. The usual 'RTFM'. Well, maybe I should put a few words here. First, he suggested to see help plot with. But plot command doesn't work here. So I am thinking this guru has told me to RTFM about the 'plot' command, but this command does not work with the z-value, what is going on here?. I was a bit confused. Next, I asked how to use the plot command instead. I never got a reply that that won't work. Just saying that plot won't work, splot is the command to use but remove set pm3d would have sufficed. But gurus cannot do this and love to admonish the dumb-user-who-does-not-want-to-RTFM. Now, usually, I would not avoid RTFM. And it is quite common for the experienced users in the Linux community to make the assumption that the other person is lazy and wants to be *always* spoon fed (BTW, it is thankfully uncommon in this list, to be fair). I have had my share of those curt commands when I was starting out learning my ways around Linux related applications -- never liked it and never practiced such an attitude toward new users unless the new user is *really* trying to shirk work. However, such gurus fail to understand, rather do not want to accept, that the person asking the query might not be in a situation where s/he can read the manual but is quite capable to do so under normal circumstances. When I asked that question, I was pressed for time and had a bunch of other stuff going on. Plus I was confused between plot and splot commands' functionality by RTFMing hastily. So I asked for an example. Now, the person probably failed to see that I was new at this thing and had already worked out an example and wanted some additional example which worked without splot, or which solved my problem. I never got a reply from him to that example, yet I got the RTFM stuff in the newsgroup from him. If I had worked for the example, one would assume I have already put some effort in to solving the problem. Given that and that I am new to this should have been enough reason to not be curt about RTFMing stuff anymore. Long story short, the posts I posted and the example I listed should have been sufficient for a reasonable person to not be condescending and to just list a working example (it didn't take long for you to list those two lines I am sure). But many people love to lengthen a thread by repeating the RTFM mantra. If that is all one needed to do, why have newsgroups in the first place, one would think. Ah, feels better! You'll want to read pp. 64ff. (For me this is more convenient, but of course there are other ways to read the gzipped ps.) Well, I had already read that portion (in the online documentation though). But from gnuplot's documentation it appears that one should have read *all* the relevant documentation also to understand any portion of it. Textbooks do not have examples for no reason you see. I was looking for one here too. Well, there is my little rant. thanks, -HS PS: I usually read the online documentation. Searching it via google is much more fruitful than searching a PDF file. Obviously, one needs to be online for that though. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
Florian Kulzer wrote: The gnuplot list is no match for the vast and mysterious powers of debian-user... How true! This is actually a very insightful observation. I have at times wondered why that list or newsgroup is so low traffic. Perhaps it is due to lack of helpful people over there. Additionally, the list is inundated with spam. It looks like an abandoned list, as if users just don't find it useful any more. So, can anyone here give an example using the plot command for this purpose? This is on Debian testing, Gnuplot 4.2. For a small number of colors something like this is may be acceptable: # START unset key set xrange [0:1] set yrange [0:1] set multiplot plot 3cols.dat using ($1):($3==1 ? $2 : 1/0) lt 1 plot 3cols.dat using ($1):($3==2 ? $2 : 1/0) lt 2 plot 3cols.dat using ($1):($3==3 ? $2 : 1/0) lt 3 plot 3cols.dat using ($1):($3==4 ? $2 : 1/0) lt 4 unset multiplot # END To scale this up sensibly for many more colors, put the plot command into a separate file that is called as a subroutine from the main program. In this subroutine you can use a counter variable for both the $3 comparison and the lt assignment. After the plot command you can increment the counter and use the if/reread trick (see the manual) to make sure that the subroutine is re-executed as many times as is necessary to loop over all the colors. Please see my earlier post. Using splot may be a better solution since I did not have to do any comparisons there. But your example is very interesting and lists some neat tricks, and it uses the 'plot' instead of 'splot'. However, I have a little doubt. You are differentiating the plotted points with the linetype, lt, right? Doesn't lt cycle back in gnuplot after a certain number of plots? I guess how many such types are available can be determined using the 'test' command in gnuplot. Before plotting, I would need to increase that number somehow, if possible. As you correctly mentioned, this approach is fine for small number of colors. thanks and regards, -HS -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
H.S. wrote: Now, usually, I would not avoid RTFM. And it is quite common for the experienced users in the Linux community to make the assumption that the other person is lazy and wants to be *always* spoon fed (BTW, it is thankfully uncommon in this list, to be fair). Oh, it used to be there couple of years back. What happened was, whenever some one gives a haughty RTFM reply, other knowledgeable people politely used to discourage him about that. After that the RTFMs gradually became here is the solution for your problem. You can find more info here. But you better RTFM before coming up with your next question. Another reason is that there is only one debian user support mailing list as opposed to one for newbies, one for x, one for technical stuff, one for programming etc., This ensured that there is at least some one out there who will answer you politely and help you out. IMHO, if a user is asking a RTFM question even after reading a manual, it just means that the manual is written badly. hth raju -- Kamaraju S Kusumanchi http://www.people.cornell.edu/pages/kk288/ http://malayamaarutham.blogspot.com/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
On Thu, Mar 27, 2008 at 18:45:21 -0400, H.S. wrote: Florian Kulzer wrote: [...] For a small number of colors something like this is may be acceptable: # START unset key set xrange [0:1] set yrange [0:1] set multiplot plot 3cols.dat using ($1):($3==1 ? $2 : 1/0) lt 1 plot 3cols.dat using ($1):($3==2 ? $2 : 1/0) lt 2 plot 3cols.dat using ($1):($3==3 ? $2 : 1/0) lt 3 plot 3cols.dat using ($1):($3==4 ? $2 : 1/0) lt 4 unset multiplot # END To scale this up sensibly for many more colors, put the plot command into a separate file that is called as a subroutine from the main program. In this subroutine you can use a counter variable for both the $3 comparison and the lt assignment. After the plot command you can increment the counter and use the if/reread trick (see the manual) to make sure that the subroutine is re-executed as many times as is necessary to loop over all the colors. Please see my earlier post. Using splot may be a better solution since I did not have to do any comparisons there. Yes, maybe. But your example is very interesting and lists some neat tricks, and it uses the 'plot' instead of 'splot'. However, I have a little doubt. You are differentiating the plotted points with the linetype, lt, right? Doesn't lt cycle back in gnuplot after a certain number of plots? Yes, it does, but the number of easily distinguishable colors is limited, too. With the above approach you can at least vary the point or line style if you have to use similar colors for more than one subset of the data. I guess how many such types are available can be determined using the 'test' command in gnuplot. Before plotting, I would need to increase that number somehow, if possible. I am not sure if this is easily possible or if it makes sense (see above). I tend not to spend time wrestling with gnuplot's style and color defaults, I simply produce an EPS output file with the default settings and then I modify the EPS file directly. Colors and line/point styles in gnuplot's EPS files can easily be changed by simple sed operations (which can be embedded as external commands in the gnuplot script). plotting, I would need to increase that number somehow, if possible. As you correctly mentioned, this approach is fine for small number of colors. One more thing worth mentioning is that the subroutine trick can also be used to loop over the columns of a dataset (using the column command), for example if you have a data file with one common x-axis and 100 y-datasets (columns) that you want plot in the same graph. (Or can the plot command do this automatically these days?) -- Regards,| http://users.icfo.es/Florian.Kulzer Florian | -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
H.S. wrote: Florian Kulzer wrote: The gnuplot list is no match for the vast and mysterious powers of debian-user... How true! This is actually a very insightful observation. I have at times wondered why that list or newsgroup is so low traffic. Perhaps it is due to lack of helpful people over there. Additionally, the list is inundated with spam. It looks like an abandoned list, as if users just don't find it useful any more. I think the gnuplot newsgroup is helpful. The people who answer questions there (like Hans Bernhard Broker etc.,) are the actual writers behind the package. They know all the nitty gritty stuff. But I agree that you do get contemptuous replies, especially when gnuplot lacks the function you are looking for. hth raju -- Kamaraju S Kusumanchi http://www.people.cornell.edu/pages/kk288/ http://malayamaarutham.blogspot.com/ -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: gnuplot: plotting each point in different color
Florian Kulzer wrote: One more thing worth mentioning is that the subroutine trick can also be used to loop over the columns of a dataset (using the column command), for example if you have a data file with one common x-axis and 100 y-datasets (columns) that you want plot in the same graph. (Or can the plot command do this automatically these days?) You might be looking for 'using'. Here is an example: gnuplot plot force.dat using 1:2 title 'Column', \ force.dat using 1:3 title 'Beam' If you have three cols in a force.dat file. This is shamelessly copied from Section 3.2 here: http://www.duke.edu/~hpgavin/gnuplot.html BTW, Gnuplot has come a long way from earlier versions (2.x, 3.x?). Recent versions ( 4.0) are rich with features and have a nifty GUI to manipulate 3-D data or surface plots with the mouse. The developers have done some pretty neat stuff over there! regards, -HS -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]