How to show values upon mouse hover in Gnuplot in SVG? - svg

After noticing the interactive gnuplot graphic upon https://lwn.net/Articles/723818/ showing country names on a mouse hover, I am wondering how to simply show the values of the points in a plot.
For example I want to hover over the "daughter bar" in https://s.natalian.org/2020-08-24/mouse-hover.svg and see 60 clearly.
However right now it just shows co-ordinates IIUC. How do I fix this?
set term svg mouse standalone
reset
$heights << EOD
dad 181
mom 170
son 100
daughter 60
EOD
unset key
set boxwidth 0.5
set style fill solid
set yrange [0:*]
plot '$heights' using 2:xtic(1) with boxes
set output '/tmp/mouse-hover.svg'
replot

You are looking for hypertext, check help hypertext.
You have to use point to anchor the hypertext.
Play with the pointsize (here ps 3) to change the area where the mouse will display the hypertext.
Since you probably don't want to display a colored point at the top of your box, make the color transparent, e.g. lc rgb 0xff123456.
Unfortunately, I haven't found (yet) anything in the gnuplot documentation how to make the font of this hypertext larger. The option font ",30" does not have any effect. If you find out please let me know. Apparently in wxt terminal you can do it (see gnuplot: Hypertext with monospace?).
Code:
### SVG standalone with hypertext
reset session
set term svg mouse standalone enhanced
set output 'tbSVGstandalone.svg'
$heights <<EOD
dad 181
mom 170
son 100
daughter 60
EOD
unset key
set boxwidth 0.5
set style fill solid
set yrange [0:*]
plot '$heights' u 2:xtic(1) w boxes,\
'' u 0:2:2 w labels hypertext point pt 7 ps 3 lc rgb 0xff123456
set output
### end of code
Result: (screenshot of SVG in Firefox. It looks like I can't place a SVG here, at least I don't know how.)

Related

gnuplot svg blank space when output to PowerPoint

I have a gnuplot SVG terminal. One issue that I'm facing when I output the files and import to powerpoint is that there is a lot of blank space especially at the Top, even though I mention that margin is 0.
Below is the example and the screen shot that shows blankspace when imported in powerpoint.
My question is how to remove blank space so I dont have to trimp or crop using another tool.
reset session
set terminal svg size 600,600 enhanced font 'Verdana,10'
set output 'output.svg'
set view 50,10
set isosample 40
set xlabel "x"
set ylabel "y"
set zlabel "f(x,y)" rotate
set pm3d noborder
set palette rgb 33,13,10
unset colorbox
set lmargin 0
set rmargin 0
set bmargin 0
set tmargin 0
set log cb
set cbrange [0.1 : *]
splot [x=-2:2] [y=-1:3] (1-x)**2+100*(y-x**2)**2 with pm3d notitle
set output
The "set margin" commands in the form you show them are designed to describe the space between the x and y borders of a 2D plot and the edges of the page. Their effect on a 3D plot rotated so that the x/y plot borders are not parallel to the page is non-obvious.
I suggest using instead a different form of the bmargin command that positions the bottom of the 3D view box at a specific screen location, followed by a scaling command to increase the vertical size by a factor of, say 1.6 or so. The vertical scale operates symmetrically above and below the center of the 3D view box. My preference would be to also get rid of the empty space inside the view box by repositioning the base plane to z=0. The additional command and their result is shown here.
set bmargin at screen 0.4 # reposition entire plot upwards
set view 50, 10, 1.0, 1.6 # increase default vertical scale by 1.6
set xyplane at 0 # remove space between base plane and bottom of surface
replot

How to apply beatiful fading edge occlusion on Gnuplot's splot function?

Hello fellow stackers,
So I am a gnuplot afficcionado and I keep trying to use gnuplot to draw all sorts of things (including molecules) using it. These days I decided that it would be awesome if I could draw polyhedran in it with this beautiful thining-edge occlusion effect that we see in the interactive javascript polyhedral images here. See how the backside of the polyhedron is drawn differently from the front side and how they change dynamically as you rotate the solid? How can I do that in gnuplot?
I agree that is a really nice representation. Gnuplot cannot currently do the equivalent of "draw the inside edges using thinner lines", but the combination of partial transparency and using the background color as the fill color for the faces creates almost the same effect.
# Generation of polyhedral vertices and faces not shown.
# Each face is an object of type polygon, e.g.
# set object 1 polygon from ... to ... to ...
# make all the faces semi-transparent
set for [i=1:20] object i fillstyle transparent solid 0.6 fillcolor bgnd border lw 2
# use pm3d depthorder sorting to render the objects
# NB: gnuplot version 5.3 required
set for [i=1:20] object i polygon depthorder
set xrange [-2:2]; set yrange [-2:2]; set zrange [-2:2]
set view equal xyz
set view 30,30,1.5
unset border
unset tics
unset key
unset label
splot NaN
Results shown below for a cube and for an icosahedron. You can rotate them interactively as with any other splot.

histogram using gnuplot for multiple data in the same graph

I am trying to plot two data series plotted in one graph (histogram) using gnuplot. One is Baseline data and other one is Optimized. The script looks like this currently.
n=50
max=0.07946462
min=0.0
reset
width=(max-min)/n #interval width
hist(x,width)=width*floor(x/width)+width/2.0 #function used to map a value
to the intervals
set term png #output terminal and file
set output "histogram.png"
set xrange [min:max]
set yrange [0:]
set style fill solid 0.5 #fillstyle
set termopt enhanced # turn on enhanced text mode
set xlabel "PowerDensity(mA/um2)"
set ylabel "Area(um2)"
set title 'Power Density Histogram'
plot 'power_density_oxili_sptp.txt' u (hist($2,width)):($1) smooth frequency
w boxes lc rgb"blue" title 'Baseline', 'power_density_oxili_sptp.txt' u
(hist($3,width)):($1) smooth frequency w boxes lc rgb"red" title 'Optimized'
The output of this will be as given
enter image description here
The problem here, I am not able to see baseline data (blue) completely,since it is hiding below the optimized data.Either I need to see both data or I need to plot histogram separately in the same graph.
Br
Sree
It looks like you want the two histograms to be transparent. For that you should set the transparent flag in your fillstyle (see help fillstyple):
set style fill transparent solid 0.5
In addition, you need to specify truecolor to get transparent areas from the standard png terminal (see help png):
set term png truecolor
Alternatively you can use the pngcairo terminal.

Gnuplot - change background color

I used gnuplot to create a graph on linux. The script creates a svg file, but its background has black and white squares. How can I create a white and clear background? The script that I used is below :
set terminal svg enhanced size 1000 1000 fname "Times" fsize 36
set autoscale
set output "plot.svg"
set title "A simple plot of x^2 vs. x"
set xlabel "x"
set ylabel "y"
plot "./data.dat" using 1:2 title ""
Those black and white squares are inserted by your viewer program, and indicate that you actually have no background. To get a white background, use the background terminal option:
set terminal svg enhanced background rgb 'white'
If your gnuplot version doesn't yet support this option, you can place a full-canvas rectangle behind the plot
set object rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb 'white' fillstyle solid noborder
...
plot x

Gnuplot 4.6.5 ylabel not visible

im running gnuplot 4.6.5 on top of ubuntu 12.04 and use the x11 terminal. I use the script as follows but the ylabel is not visible (xlabel is fine). What i have to do to fix it? offset?
thanks for help
plot "512bytesCBR3000client4server1numofnodes.txt" using 1:2 title 'NativeOF' with linespoints lw 2 ps 3 pt 6 lt 3
set grid
set ylabel "End to end delay"
set xlabel "number of nodes"
Normally, you have to do all the settings (set xlabel, set ylabel, set grid) before you call plot if you want them them to show up in the plot. I am not sure why set xlabel is working for you unless you set it in a previous plot or while trying commands from the gnuplot command line.
Try moving the plot command to the end of the file.
Sometimes, this might be related to the margins of the canvas. Therefore, might be wise to play with the margin settings, for example:
# other grid settings
set lmargin 10
set rmargin 10
set tmargin 5
set bmargin 5
# plot command

Resources