Showing posts with label svg. Show all posts
Showing posts with label svg. Show all posts

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" >
<title>gnuplot_plot_1</title>
<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" >
<title>gnuplot_plot_1</title>
<g style="stroke-dasharray: 7,2,2,2,2,2; 
  fill:none; color:red; stroke:currentColor; 
  stroke-width:1.00; stroke-linecap:butt; 
  stroke-linejoin:miter">

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".

Monday, June 4, 2012

Plot an interactive svg graph using gnuplot

In this post an example of plotting an interactive svg graph using gnuplot is talked.

First, run the following gnuplot plotting script.

set term svg mouse jsdir "./js"  
set output "sincos.svg"
plot sin(x) w l lc rgb"#ff0000", cos(x) w l lc rgb"#00ff00"
set output

And a file called "sincos.svg" is plotted. As we specified in the script that the javascript file is in directory "./js", "gnuplot-dir/share/js" have to be copied to the current directory (windows operating system, and if you use linux maybe the directory should be /usr/local/share/gnuplot/gnuplot-version/js). This time open the file, and you can find when you click the graph, the coordinate of the current point will be displayed. And when you click the legend, the cooresponding line will be invisible, and click it again, the line will visible.

The jsdir can also be a url location. And this is is usually appropriate if you are embedding the svg into a web page. For example, command --- set term svg mouse jsdir "http://gnuplot.sourceforge.net/demo_svg_4.6/" can be used.

set term svg mouse jsdir "http://gnuplot.sourceforge.net/demo_svg_4.6/"
set output "sincos.svg"
plot sin(x) w l lc rgb"#ff0000", cos(x) w l lc rgb"#00ff00"
set output
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.