Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to produce dashed lines in gnuplot 5 using TikZ terminal?

Tags:

gnuplot

I have recently upgraded to gnuplot 5 and have been unable to produce dashed lines using the TikZ terminal. Running these commands:

set term tikz
set output "test.tex"
test

produce dashed line types in gnuplot 4.6 (first image), but only solid ones in gnuplot 5 (second image). Is there a way to fix this without downgrading?

I have tried setting different values for the dashlength terminal option, but that didn't help.

like image 544
Tymric Avatar asked Feb 10 '15 17:02

Tymric


People also ask

How do I plot functions using gnuplot using PGF/TikZ?

PGF/TikZ provides a convenient mechanism for plotting functions using GNUPLOT . To run this example for the first time you have to do the following: GNUPLOT must be installed on your system. Try typing gnuplot on the command line to see if it's installed.

How do I run Gnuplot in Tex?

Try typing gnuplot on the command line to see if it's installed. Windows users may have to rename wgnuplot to gnuplot. You must allow TeX to run external programs. The command line option to enable this is usually --shell-escape or --enable-write18 PGF will call GNUPLOT for you and store the data in a file.

Why can't I get TikZ to work with set terminal table?

@rommel The problem is that set terminal table is deprecated in recent versions of GNUPLOT (from 2005 and newer). You either have to use an old version of GNUPLOT, or install a recent development build of TikZ. On a Mac you have to use fink to install gnuplot.

What is the best 3D plotting terminal?

You could try the GNUPLOT TikZ terminal. You should also check out pgfplots. The development version may have support for 3D-plots. The GNUPLOT TikZ terminal works fantastic!


1 Answers

With 5.0 gnuplot has changed its way to deal with dashed lines. All line types are solid by default, this is what the test command shows you.

To enable dashed lines, use the new dashtype keyword, e.g

plot for [i=1:4] i*x dashtype i

That works for all terminals which support dashed lines.

Note, that with dashtype you can also specify your own dash patterns.

Example script:

set terminal lua tikz linewidth 3 standalone
set output 'dash.tex'    
unset key

set linetype 1 dashtype 2
set linetype 2 dashtype '..-'
set linetype 3 dashtype (2,2,4,4,6,6)
plot for [i=1:3] i*x

enter image description here

like image 138
Christoph Avatar answered Nov 12 '22 22:11

Christoph