Saturday, July 7, 2012

Self-defined linestyle under gnuplot svg terminal

Gnuplot have defined a series of line styles. But maybe you still have not find the one which is just appropriate for you. For example,when you want to use a dash-dot-dot line, you find there is not such a linestyle.

When you are using svg teminal (self-defined linestyle under postscript terminal will be talked in another post) this problem can solved easily. Fisrt, plot your file with solid line.

set term svg
set output "sin.svg"
plot sin(x) with line
set output

After that, open the svg file with a text-editor, and find codes like the following:

<g id="gnuplot_plot_1" >
<g style=" fill:none; color:red; 
  stroke:currentColor; stroke-width:1.00; 
  stroke-linecap:butt; stroke-linejoin:miter">

Then change it to

<g id="gnuplot_plot_1" >
<g style="stroke-dasharray: 7,2,2,2,2,2; 
  fill:none; color:red; stroke:currentColor; 
  stroke-width:1.00; stroke-linecap:butt; 

This time open your svg file, and you find the line sytle has changed. The follwing picture is a screen capture of "sin.svg".

Fig.1 Self-defined linestyle under gnuplot svg terminal

To further understand this post, you may google "stroke-dasharray + svg".

No comments:

Post a Comment

Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.