gnuplot

In gnuplot, is hypertext available also for bargraphs? I see a popup in term svg, but did not find a way to change it


I would like to create active content evaluations of KPIs. For that I would like to use the mouse over function as availabe e.g. for the point style (hypertext.dem).

Is or will this be available for bargraphs also? I the plot I see a popup displaying my "using" statements, but I did not find a way to modify it with the "with labels hypertext" statements.

enter image description here

The only workaround I see for now is to add another plot on top with point style that would popup the hypertext.

I tried things in gnuplot version 6.0 and 6.0.2.


Solution

  • A solution to this questions probably requires some "tricks". As far as I know, with labels hypertext can only use anchor points. It would be nice if there might be a feature for hypertext for arbitrary areas, e.g. like filledcurves on a map (maybe in the future?). However, it wouldn't be gnuplot if there isn't a workaround. At least for the simpler case of bars or rectangles.

    So, if your mouse is above the anchor point, the hypertext will be displayed.

    Hence, for the simplest case

    1. plot an anchor point on top at the top of the bar
    2. set the size of the point such that it covers approximately the width of the bar. Keep in mind that the proportions of point to canvas size might be different in different terminals
    3. make the anchor points invisible, by setting color fully transparent, e.g. lc rgb 0xff123456, the mouse will still react, although the point is invisible

    This will look like this: (just for illustration, the alpha channel is not set to full transparency, but only to 0xee). The corresponding part of the plot command would look like this:

        '' u 1:2:2 w labels hypertext point pt 5 ps 5 lc rgb 0xee123456
    

    enter image description here

    However, if you want the whole bar to react to mouse hovering, simply place several anchor points on top of each bar.

    Script:

    ### hypertext for the whole area of bar grahps
    reset session
    
    # create some random test data
    set table $Data
        set samples 9
        plot '+' u ($0+1):(rand(0)*10+1) w table
    unset table
    
    set boxwidth 0.9
    set style fill solid 0.5
    set yrange[0:]
    set key noautotitle
    
    stats $Data u 2 nooutput
    Nmax = 8
    dy0  = STATS_max/(Nmax-1)
    
    plot $Data u 1:2 w boxes lc rgb 0xff0000, \
         for [i=0:Nmax] $Data u 1:(dy=$2/ceil($2/dy0), i*dy>1.1*$2 ? NaN : i*dy):2 \
             w labels hypertext point pt 5 ps 5 lc rgb 0xee123456
    ### end of script
    

    Result:

    Screenshot from qt terminal:

    enter image description here

    Unfortunately, you cannot upload SVGs in StackOverflow, hence, here a screen capture from SVG in Firefox browser: set color to full transparency, i.e. lc rgb 0xff123456 to let the squares disappear.

    For creating a SVG, modify the script to something like this:

    ...
    set term svg mouse standalone
    set output "SO79497533.svg"
    plot ...
    set output
    

    enter image description here