Menu

#409 Functionality of gnuplot-lua-tikz.lua

None
closed-accepted
nobody
None
5
2014-10-26
2014-10-05
uh1
No

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 '\'

Discussion

  • Ethan Merritt

    Ethan Merritt - 2014-10-12

    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.

     
    • uh1

      uh1 - 2014-10-13

      See the attached .diff. As this is the3 first .diff I generated, please let me know if something is wrong.

       
  • Christoph Bersch

    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?

    set label '\node[gp refnode,name=mynode1]{bla}' center at 1,1
    
     
    • uh1

      uh1 - 2014-10-15

      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

      set label center 'bla' at -3,-0.5 font ',8'
      

      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.

      set label '\node[gp refnode,name=mynode1]{bla}' center at 1,1
      

      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.

       
      • Christoph Bersch

        Ok, I had a closer look at this and its a bug :)

        The check you pointed out test if fontsize is nil, but gfx.parse_font_string returns false if it didn't succeed to parse a size. So the check must be if fontsize then, which test for fontsize being something else than false or nil. I attached a patch to fix this.

         

        Last edit: Christoph Bersch 2014-10-16
        • uh1

          uh1 - 2014-10-17

          Very nice, thanks! Sorry for not seeing that myself.

           
  • Ethan Merritt

    Ethan Merritt - 2014-10-17

    Applied to CVS for 5.0 and 5.1

    thanks for testing.

     
  • Ethan Merritt

    Ethan Merritt - 2014-10-17
    • status: open --> pending-accepted
    • Group: -->
     
  • Ethan Merritt

    Ethan Merritt - 2014-10-26
    • status: pending-accepted --> closed-accepted
     

Log in to post a comment.