This question actually arose from this question.
From help hyptertext
:
Some terminals (wxt, qt, svg, canvas, win) allow you to attach hypertext to specific points on the graph or elsewhere on the canvas. When the mouse hovers over the anchor point, a pop-up box containing the text is displayed.
A plot command would for example look like this:
plot FILE u 1:2:3 w labels hypertext point pt 7
This works fine, however, when creating a SVG file and plotting just with labels
, but without hypertext, the browser shows nevertheless some hypertext, e.g. gnuplot_plot_1
.
A minimal example to reproduce this issue:
Script:
### unwanted hypertext in SVG when plot with labels
reset session
set table $Data
set samples 20
plot '+' u (rand(0)*100):(rand(0)*100) w table
unset table
set term svg mouse standalone
set output "SO79507708.svg"
plot $Data u 1:2:0 w labels notitle
set output
### end of script
Result: (screen capture from Firefox browser, since StackOverflow doesn't allow SVG uploads)
If you look at the SVG source code, you will find this line:
...
<g id="gnuplot_plot_1" fill="none"><title>gnuplot_plot_1</title>
...
Apparently, the SVG terminal library is inserting some default text as . How to get rid of this title?
The following changes do not help:
set term svg mouse standalone name '' # this will just remove the leading `gnuplot`
unset title
set key noautotitle
plot FILE u ..... notitle
But all these latter titles are apparently not that title in the SVG.
So, again the question is:
How can I avoid the default hypertext in SVG when just plotting with labels only?
Well, I could edit the SVG with some external tool and replace <title>gnuplot_plot_.*?</title>
with <title></title>
, which, however, would not be very practical. Is there a gnuplot solution or maybe an undocumented option?
The hypertext that is shown is chosen from
text attached to that point, if any
the title of the plot component, if there is one
the generic title of that element in the output file
So you need only a trivial change
# hypertext is generic plot identifier
plot FILE u ..... notitle
# hypertext is a blank title
plot FILE u ..... title " "
Note however that this is implemented in a separate file gnuplot_svg.js. When you select the svg terminal you can either specify the standalone
option to insert a copy of this file from your current machine's installation directory into the svg output file or you can instead give a URL telling where to pull the script file from (in which case there is no copy in the output file, only the URL) set term svg mouse jsdir "my.webserver.org://gnuplot/js"
. Either way you could change the hypertext behavior for all plots that use that copy of the gnuplot_svg.js script by editing the script file itself rather than the gnuplot plotting scripts that either copy it or link to it.