From: lilu29 <lul...@gm...> - 2009-01-09 17:36:42
|
Hi, everyone Gnuplot4.3 has a new type for drawing circle, and in its manual, it says "An optinal 4th column may be used to specify color information". But it doesn't give any example of using this function. All its examples for drawing circle are specifying color statically. What I want to do is: I want to draw circles using following input data, each circle is defined by one line, the 4th column is the painting color. What should I do???? I tried plot "file" using 1:2:3:4 with circles lc rgb $4 plot "file" using 1:2:3:4 with circles lc rgb variable they all don't work. Can someone give me some hints? Thank you very much! My input data's format is: x y radius color 2 3 4 "yellow" 1 1 5 "red" ............. -- View this message in context: http://www.nabble.com/How-to-dynamically-specify-color-for-drawing-circle-in-Gnuplot4.3-tp21376845p21376845.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: lilu29 <lul...@gm...> - 2009-01-10 03:43:22
|
Hi, guys Nobody answers this question, so I spent nearly 4 hours to hack Gnuplot in order to find out how to use this function for specifying color from data file. I didn't read its source code before, so starting from the scratch. The requirement: Gnuplot4.3 source code, grep That's enough. This post only represents my own opinion, so there may be some faults, welcome to point them out. Because, when I hacked the source code, I added a few print statements, maybe there exists some wrong line numbers. But I wrote out the full function names and variable names, wrong line numbers don't effect reading. 1) Where is the main function for starting The entry main function is in "plot.c": int gnu_main(), or int main() 2) Which function plots circles or other objects void place_objects() : graphics.c In this function, you can find "case OBJ_CIRCLE". You can also see "do_arc(x1, y1, radius, e->arc_begin, e->arc_end,0)" do_arc() really draws circles.:term.c One of its parameters "style" controls the drawing style. 3) The drawing style mentioned in (2) is set in place_objects and actually from object* listhead which is the first parameters in this function. We can also find out that this parameter is a list of objects, so gnuplot plots objects in this list one by one. 4) Which function invokes place_objects() and give parameter "object* listhead" void do_plot(): graphics.c On line 1567 of graphics.c, it invokes place_object(first_object,****), first_object is a global variable which a head of object list. void refresh_request(): command.c --this function invokes "do_plot(first_plot)" first_plot is also a global variable set in eval_plots(): plot2d.c On line 1414 in this file, we see top_ptr=&(first_plot) In this file, we also see a imporant variable "struct curve_poins* this_plot", this variable specifies the drawing style. We can find many drawing properties set in this function. But the most important statement is line 1993:(get_data(this_plot)) 5)get_data(this_plot): plot2d.c In this function, we can find "TBOOLEAN variable_color", it decides whether we can specify color dynamically. Another important variable for setting color value (RGB value) is "double variable_color_value ". This value is real color value for drawing objects. This function also points out: the min_cols and max_cols of data file for drawing circle are 3 and 4. (line 472) The comment says /*3+ possible variable color*/ So we really confirm that color for each circle can be set at the 4th column of data file. we can see that the value of variable_color_value is from data file: "variable_color_value = v[--j]" v[] is a array read from data file. This array is also processed through some function specified at "using func($1):func($2)***" 6) Now the important is: how to let variable_color ==true on line 340 in plot2d.c, we can find out two conditions can make this value true. We track the first condition, "current_plot->lp_properties.pm3d_color.type==TC_RGB" color.type is set at "parse_colorspec()", while "parse_colorspec()" is invoked in lp_parse(). Both functions are in misc.c. >From " lp_parse()", we know that we need to specify "lt" in the command line to invoke parse_colorspec() >From "parse_colorspec" we need to specify "rgb " in command. In conclusion, to set circle color from data file, we should: a, the format of data file x y radius color_clue ps: color_clue can be the real RGB value or any varialbe which we can calculate RGB from it b, the rgb command plot "data_file" using 1:2:3:yourColorFunc($4, or the total four columns) with circles lt rgb var or plot "data_file" using 1:2:3:yourColorFunc($4, or the total four columns) with circles lt rgbcolor var or plot "data_file" using 1:2:3:yourColorFunc($4, or the total four columns) with circles lt rgbcolor variable or plot "data_file" using 1:2:3:yourColorFunc($4, or the total four columns) with circles lt rgb variable (rgb==rgbcolor; var==variable) This command is enough, we do not need to do any other command. lilu29 wrote: > > Hi, everyone > Gnuplot4.3 has a new type for drawing circle, and in its manual, it says > "An optinal 4th column may be used to specify color information". But it > doesn't give any example of using this function. All its examples for > drawing circle are specifying color statically. > > What I want to do is: I want to draw circles using following input data, > each circle is defined by one line, the 4th column is the painting color. > What should I do???? I tried > plot "file" using 1:2:3:4 with circles lc rgb $4 > plot "file" using 1:2:3:4 with circles lc rgb variable > they all don't work. > Can someone give me some hints? > > Thank you very much! > > My input data's format is: > x y radius color > 2 3 4 "yellow" > 1 1 5 "red" > ............. > > > > -- View this message in context: http://www.nabble.com/How-to-dynamically-specify-color-for-drawing-circle-in-Gnuplot4.3-tp21376845p21384557.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: v_2e <v_...@uk...> - 2010-03-14 10:15:10
|
Hello! TonyM wrote: > > I'm having the same problem. > Can you please provide a working example of both the data and the code > used to run. > I can provide my working example. It is very simple. I have a test_map.txt file with contents like this: 0 0 5 7 -90 0 2 4 90 0 2 4 -120 0 1 3 The columns mean x-coordinate, y-coordinate, radius and a color respectively. And I can easily plot the circles from such file just by using this command line: $ gnuplot -persist -e 'plot "test_map.txt" using 1:2:3:4 with circles lc variable' Or if I would like to have filled circles, I can use: $ gnuplot -persist -e 'plot "test_map.txt" using 1:2:3:4 with circles fill solid lc variable' And that is all! :) Hope, it will help you! -- View this message in context: http://old.nabble.com/How-to-dynamically-specify-color-for-drawing-circle-in-Gnuplot4.3-tp21376845p27892177.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: exprexxo <exp...@gm...> - 2010-05-14 19:01:15
|
Here is another example without a file set title "A Venn Diagram" unset border unset xtics unset ytics set size ratio -1 set xrange [-10:10] set yrange [-10:10] plot '-' using 1:2:3:4 with circles lc rgb variable fs transparent solid 0.15 noborder 2 2 4 1 -2 2 5 200 0 -2 5 3 e However I can not figure out what numbers I should be using for RGB other than 200 gives me blue. -- View this message in context: http://old.nabble.com/How-to-dynamically-specify-color-for-drawing-circle-in-Gnuplot4.3-tp21376845p28563176.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: Thomas S. <t.s...@fz...> - 2010-05-14 20:27:33
|
rgbcolors are made of 3 components - red, green, and blue, represented as hexadecimal values: #RRGGBB the 3 color values are in the range 0-255, so the rgbcolor as a decimal value is: 65536 * red + 256 * green + blue you read in this decimal value in your plot command, a value of '200' means that the red and green components are zero - the number is too small - so the circle is blue. some rgbcolor value examples: red: 65536*255 = 16711680 green: 256*255 = 65280 blue: 255 instead of rgbcolors you could use a color palette: plot ... linecolor palette ... exprexxo wrote: > > Here is another example without a file > > set title "A Venn Diagram" > unset border > unset xtics > unset ytics > set size ratio -1 > set xrange [-10:10] > set yrange [-10:10] > plot '-' using 1:2:3:4 with circles lc rgb variable fs transparent solid > 0.15 noborder > 2 2 4 1 > -2 2 5 200 > 0 -2 5 3 > e > > However I can not figure out what numbers I should be using for RGB other > than 200 gives me blue. > -- View this message in context: http://old.nabble.com/How-to-dynamically-specify-color-for-drawing-circle-in-Gnuplot4.3-tp21376845p28563985.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
From: exprexxo <exp...@gm...> - 2010-05-14 21:35:44
|
Perfect that was exactly what I needed to make the example even better, So here is a Circle Example that does a Venn diagram with a red, blue and a green colored circle set title "A Venn Diagram" unset border unset xtics unset ytics set size ratio -1 set xrange [-10:10] set yrange [-10:10] plot '-' using 1:2:3:4 with circles lc rgb variable fs transparent solid 0.15 noborder 2 2 4 167116800 -2 2 5 65280 0 -2 5 255 e -- View this message in context: http://old.nabble.com/How-to-dynamically-specify-color-for-drawing-circle-in-Gnuplot4.3-tp21376845p28564508.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |