Menu

#692 lua tikz: Support custom dash types

Version 6
closed-accepted
nobody
None
5
2025-07-21
2014-06-10
No

This patch adds support for custom dash types to the lua tikz terminal. It also introduces a dashlength terminal option and now the dash patterns scale with the current line width.

The old TikZ styles gp lt plot 0 up to gp lt plot 7 and the corresponding ... add style are kept. They don't do anything, but were also used to hook in from LaTeX.

For testing I used:

set terminal lua tikz standalone

set output 'dashlength-1.tex'
plot x dt 2, 2*x dt 2 lw 5, 3*x dt '.-', 4*x dt '.-' lw 5

set output 'dashlength-0_5.tex'

set termoption dashlength 0.5
replot

set output
system('pdflatex dashlength-1 && pdflatex dashlength-0_5')
1 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2014-06-11

    It doesn't work for me:

    gnuplot> set term tikz standalone
    Terminal type set to 'tikz'
    Options are 'latex nopreamble color standalone nogparrows notikzarrows nogppoints picenvironment nooriginreset bitmap rgbimage noclip notightboundingbox noexternalimages '
    gnuplot> set output 'dt.tex'
    gnuplot> load 'dashtypes.dem'
             "dashtypes.dem", line 37: /usr/local/share/gnuplot/5.0/lua/gnuplot-tikz.lua:1496: attempt to get length of field 'linetypes' (a nil value)
    stack t
    

    By the way, a lua error totally hoses keyboard input to a gnuplot session. Is there any way to avoid that?

     
  • Christoph Bersch

    Thanks for the feedback.

    I fixed the problem you see, but for some reason the code works fine with my test script which I posted, but not with dashtypes.dem. I'll try to fix that an then update the patch. So there are some different settings involved when plotting a function or drawing arrows.

    About the lua error, I have no idea. This patch is my first code written with lua :)

     
  • Christoph Bersch

    I fixed this. With the attached patch, the dashtypes.dem demo works fine. I used

    set terminal lua tikz standalone
    set output '| sed "s/_/\\\\_/" > dt.tex'
    load 'dashtypes.dem'
    

    The sed command replaces only a single underscore which would give an error when compiling with pdflatex.

    What seems strange to me is, that the patch works fine if I use set terminal lua tikz, but doesn't work when using set terminal tikz. In the latter case all lines are solid. Don't know what the problem is in this case.

     
  • Ethan Merritt

    Ethan Merritt - 2014-06-12
    • status: open --> closed-accepted
     
  • Ethan Merritt

    Ethan Merritt - 2014-06-12

    Applied. Thanks.

    The difference between "set term lua tikz" and "set term tikz" arose because there are two separate TERM_TABLE structures. Your patch only added the new entry point to one of them.

     

Log in to post a comment.

MongoDB Logo MongoDB