|
From: Kevin K. <kk...@gm...> - 2025-09-11 15:41:40
|
I have the following gnuplot data file:
1 4 foo 1
2 3 bar 2
5 8 baz 1
I have the following gnuplot command:
set terminal qt
label_text(str1) = sprintf("%s", stringcolumn(str1))
plot "gnuplot_data.txt" using 1:2:(label_text(3)) with labels hypertext
notitle
pause -1
How can I color code the points based on the value of the 4th column? I
know how to do this when not using hypertext labels, but cannot figure it
out when the 3rd field of the "using" statement is dedicated to specifying
the 3rd column for the label text.
Thanks
|
|
From: Walter H. <wh...@bf...> - 2025-10-27 17:06:52
|
I am no sure that i understand you problem, but
there is a demo called "data-dependent coloring" maybe that is a starting point ?
CU
________________________________________
Von: Kevin Klein <kk...@gm...>
Gesendet: Donnerstag, 11. September 2025 17:41:21
An: gnu...@li...
Betreff: [Gnuplot-info] coloring points based on column value when also using hypertext labels
I have the following gnuplot data file:
1 4 foo 1
2 3 bar 2
5 8 baz 1
I have the following gnuplot command:
set terminal qt
label_text(str1) = sprintf("%s", stringcolumn(str1))
plot "gnuplot_data.txt" using 1:2:(label_text(3)) with labels hypertext
notitle
pause -1
How can I color code the points based on the value of the 4th column? I
know how to do this when not using hypertext labels, but cannot figure it
out when the 3rd field of the "using" statement is dedicated to specifying
the 3rd column for the label text.
Thanks
_______________________________________________
gnuplot-info mailing list
gnu...@li...
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
|
|
From: theozh <th...@gm...> - 2026-04-01 08:48:39
|
in case this is still of interest...
If the values in the 4th column are numbers, you could pick the RGB-value from a string.
Check for example `help linecolor variable` and `help word`
Hope this helps, Theo.
### point color depending on column value
reset session
$Data <<EOD
1 4 foo 1
2 3 bar 3
5 8 baz 2
EOD
set key noautotitle
myLabel(col) = sprintf("%s", strcol(col))
myColor(col) = int(word("0xff0000 0x00ff00 0x0000ff", int(column(col))))
plot $Data u 1:2:(myLabel(3)):(myColor(4)) w labels hypertext point pt 7 lc rgb var
### end of script
|
|
From: Michael S. <Mic...@bo...> - 2026-04-01 16:26:54
|
Theozh, Thanks for the script. I learned about some nice gnuplot features by reading it and testing it. Is there a way to associate hypertext with objects? I would like to add hypertext labels for the moon phases it https://boardsailor.com/palo_alto/third_avenue_28_day_forecast.svg Thanks, Michael On Wed, Apr 1, 2026 at 1:48 AM theozh via gnuplot-info < gnu...@li...> wrote: > in case this is still of interest... > If the values in the 4th column are numbers, you could pick the RGB-value > from a string. > Check for example `help linecolor variable` and `help word` > > Hope this helps, Theo. > > ### point color depending on column value > reset session > > $Data <<EOD > 1 4 foo 1 > 2 3 bar 3 > 5 8 baz 2 > EOD > > set key noautotitle > myLabel(col) = sprintf("%s", strcol(col)) > myColor(col) = int(word("0xff0000 0x00ff00 0x0000ff", int(column(col)))) > > plot $Data u 1:2:(myLabel(3)):(myColor(4)) w labels hypertext point pt 7 > lc rgb var > ### end of script > > > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: theozh <th...@gm...> - 2026-04-02 08:44:02
|
Hi Michael, I'm not aware that there is hypertext attached to objects, maybe in newer gnuplot versions. A simple solution would be to simply plot a hypertext `with labels` with a fully transparent point (`lc rgb 0xff123456`) on top of your object. You can set the hypertext pointsize a bit larger, e.g. ps 7, so that hovering with the mouse over the point will react earlier. However, I noticed that at least in wxt terminal >gnuplot 5.2.8, this doesn't seem to work anymore, i.e. you have to precisely hit the point. On qt terminal it still seems to work, haven't tested SVG. Your moon phases remind me to an earlier answer on StackOverflow: https://stackoverflow.com/a/77224783 Putting this together with the hypertext it could be something like this: ### moon phases with hypertext reset session set angles degrees set size ratio -1 # for northern hemisphere # x,y, phase, size, description # phases: 0=new moon, 0.5=full moon, 1=new moon $MoonPos <<EOD 0 0 0.00 1.0 "new moon" 3 0 0.125 1.0 "waxing crescent" 6 0 0.25 1.0 "first quarter" 9 0 0.375 1.0 "waxing gibbous" 12 0 0.50 1.0 "full moon" 15 0 0.625 1.0 "waning gibbous" 18 0 0.75 1.0 "last quarter" 21 0 0.875 1.0 "waning crescent" 24 0 1.00 1.0 "new moon" EOD array Moon[n_moon=40] # high enough even number to get a "round" shape r(x) = 2*(x - abs(x)) + 1 MoonX(n) = (a=360./n_moon*$0+90, s=$MoonPos[i/2+1], p=word(s,3), A=word(s,4), \ A*cos(a)*(i%2 ? a<=270 ? r(p-0.5) : r(0.5-p) : \ (a<=270 ^ p<=0.5) ? -r(p-0.5) : r(0.5-p)) + word(s,1)) MoonY(n) = A*sin(a) + word(s,2) set key noautotitle set style fill noborder set xrange[-2:26] plot for [i=0:|$MoonPos|*2-1] Moon u (MoonX(0)):(MoonY(0)):(i%2?0xffff00:0x000077) w filledcurves lc rgb var, \ $MoonPos u 1:2:5 w labels hypertext point pt 7 ps 7 lc rgb 0xff123456 ### end of script Am 01.04.2026 um 18:26 schrieb Michael Schuh: > Theozh, > > Thanks for the script. I learned about some nice gnuplot features by reading it and testing it. > > Is there a way to associate hypertext with objects? I would like to add hypertext labels for the moon phases it https://boardsailor.com/palo_alto/third_avenue_28_day_forecast.svg <https://boardsailor.com/palo_alto/third_avenue_28_day_forecast.svg> > > Thanks, > Michael > |