In the gnuplot-lua-tikz.lua file is a comment:
% to add an empty label with the referenceable name "my node"
% to the plot, just add the following line to your gnuplot
% file:
%
% set label "" at 1,1 font ",gp refnode,name=my node"
%
This did not work for me, but changing the code from line 2235 onwards:
term.set_font = function(font)
local fontsize = nil
gfx.text_font, fontsize = gfx.parse_font_string(font)
if fontsize ~= nil then
gfx.text_font, fontsize = gfx.parse_font_string(font)
term.h_char = pgf.DEFAULT_FONT_H_CHAR * (fontsize/10) * (pgf.DEFAULT_RESOLUTION/1000)
term.v_char = pgf.DEFAULT_FONT_V_CHAR * (fontsize/10) * (pgf.DEFAULT_RESOLUTION/1000)
end
return 1
end
to
term.set_font = function(font)
local fontsize = nil
gfx.text_font, fontsize = gfx.parse_font_string(font)
if fontsize ~= nil then
-- term.h_char = pgf.DEFAULT_FONT_H_CHAR * (fontsize/10) * (pgf.DEFAULT_RESOLUTION/1000)
-- term.v_char = pgf.DEFAULT_FONT_V_CHAR * (fontsize/10) * (pgf.DEFAULT_RESOLUTION/1000)
end
return 1
end
allows the use of
set label center "" at 0,1 font ',gp refnode,name=mynode1'
While it would be preferable to have a clean way of passing options to a tikz node, maybe something along the lines of
set label "bla" at 0,1 node 'here come pure tikz options'
I think the above is a reasonable work around, as
a) the tikz terminal is specially for LaTeX and LaTeX fonts should also be changeable via
specific commands that can be defined in the preamble, e.g.
set label '\sanscourier bla' at 0,1
b) It is very helpful to be able to avoid fiddling around with gnuplot and tikz coordinates that do not match.
set label '\'
Code you attach an actual patch file? The in-line code above seems to have been mangled, or at least I can't figure out how to read it as a patch.
See the attached .diff. As this is the3 first .diff I generated, please let me know if something is wrong.
I guess this comment is left over from some early version of the
gnuplot-tikz.lua
script. And I think you shouldn't blame gnuplot for not allowing you to misuse some parameters for something completely different :) Your proposal would probably break something else which makes use of the actual font option.One of the advantages of the lua tikz terminal is, that you can change the respective script without the need to compile gnuplot yourself, so you can easily adapt it to your needs.
On the other hand, have you tried, if a label containing a whole node definition would work?
Yes, I know that this is an ugly proposal (and for sure I didn't want to blame gnuplot!), but, as I mentioned, I think it's not unreasonable, if properly documented, as
still works and changes the font size accordingly (even though, admittedly, not in combination with gp refnode,name=mynode1, but that is what was broken anyway).
Note that specifying a font by its name, e.g. arial won't work anyway, as font related stuff is very dependent upon pdftex, xetex, luatex. If this is planned to be working, it would be most sensible to adapt the font commands to luatex (respectively fontspec), as pdftex e.g. runs quickly into memory issues if tikzpictures are used.
Yes, I tried a label containing a whole node.
doesn't work, even in combination with a \tikz{}-command surounding it and using remember picture, overlay as options (the tikzpicture in a tikzpicture approach) or \pgfextra{} as an approach.
Ok, I had a closer look at this and its a bug :)
The check you pointed out test if
fontsize
isnil
, butgfx.parse_font_string
returnsfalse
if it didn't succeed to parse a size. So the check must beif fontsize then
, which test forfontsize
being something else thanfalse
ornil
. I attached a patch to fix this.Last edit: Christoph Bersch 2014-10-16
Very nice, thanks! Sorry for not seeing that myself.
Applied to CVS for 5.0 and 5.1
thanks for testing.