Next: , Previous: Introduction to SvgPlot, Up: Top


2 Simple example of SvgPlot

This is an example of SvgPlot library. This example shows how to:

  1. Plot lines and arrows.
  2. Plot geometrical figures.
  3. Plot ellipses and circles.
  4. Plot text.
  5. Show images from png or jpeg file.

This is the example:

     function plotExample1()
     	% Open SVG file
     	svgPlot=SvgPlotNew('plotExample1.svg');
     
     	% Sets line witdh and colors
     	svgPlot=SvgPlotSetLineWidth(svgPlot, 4);
     	svgPlot=SvgPlotSetForegroundColor(svgPlot, "blue");
     	svgPlot=SvgPlotSetBackgroundColor(svgPlot, "red");
     
     	% Draw some lines
     	svgPlot=SvgPlotLine(svgPlot, 5, 5, 790, 300);
     	% Poly-lines can be filled. Set true last parameter
     	svgPlot=SvgPlotPolyLine(svgPlot, [5, 790, 300], [5, 300, 200], true);
     
     	% Draw set of arrows
     	for x=[0:30:360]*pi/180
     		svgPlot=SvgPlotArrow(svgPlot, 400, 300, 400+100*cos(x), 300+100*sin(x) );
     		% Print text "Arrow"
     		svgPlot=SvgPlotText(svgPlot, 400+120*cos(x), 300+120*sin(x), "arrow" );
     	endfor
     
     	% Draw circles and ellipses
     	svgPlot=SvgPlotCircle(svgPlot, 400,300,100, false);
     	svgPlot=SvgPlotEllipse(svgPlot, 400,300,100,200, false);
     
     	% You can append images too
     	% svgPlot=SvgPlotImage(svgPlot, 400, 300, 450, 350, './toys_section.png');
     
     	% Close SVG figure
     	svgPlot=SvgPlotClose(svgPlot);
     
     	% In QtOctave, you can show your figures. Uncomment next lines in QtOctave to show it.
     	svgcanvasload(1, 'plotExample1.svg');
     	svgcanvassave(1, 800, 600, 'plotExample1.png');
     endfunction
examples/plotExample1.png

You must always open your SVG output file using SvgPlotNew function:

— Function File: SvgPlotNew (fileName, width, height)

Build new SvgPlot object. SvgPlot object is a file with a plot in svg file format. This file can be loaded in QtOctave using svgcanvasload. fileName is name of file to save svg plot. width Width of plot in pixels. height Height of plot in pixels. Files opened with SvgPlotNew must be closed with SvgPlotClose. See also: SvgPlotClose

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

You must close your SVG output using SvgPlotClose function:

— Function File: SvgPlotClose (svgPlot)

Close a SvgPlot object. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

Between SvgPlotNew and SvgPlotClose you can use:

— Function File: SvgPlotImage (svgPlot, x0, y0, x1, y1, imageFile )

Draw image file imageFile from (x0,y0) to (x1,y1). See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotPolyLine (svgPlot, x, y, fill_ok)

Plot polyline from (x,y) vectors. If fill_ok is true, poly-line is closed and filled. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotCircle (svgPlot, x, y, r, fill_ok )

Draw an ellipse. If fill_ok is true, ellipse is filled. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotText (svgPlot, x, y, text)

Draw text in (x,y). See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotSetBackgroundColor (svgPlot, color)

Set foreground color to svgPlot. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotEllipse (svgPlot, x, y, rx, ry, fill_ok )

Draw an ellipse. If fill_ok is true, ellipse is filled. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotLegent (svgPlot, plotData, x, y)

Plot legent of plotData in (x,y). See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotNew (fileName, width, height)

Build new SvgPlot object. SvgPlot object is a file with a plot in svg file format. This file can be loaded in QtOctave using svgcanvasload. fileName is name of file to save svg plot. width Width of plot in pixels. height Height of plot in pixels. Files opened with SvgPlotNew must be closed with SvgPlotClose. See also: SvgPlotClose

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotLine (svgPlot, x0, y0, x1, y1 )

Plot line from (x0,y0) to (x1,y1). See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotDraw (svgPlot, plotData, x, y, width, height)

Make a new plot of plotData in (x,y) coordinates and size (width, height). See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotArrow (svgPlot, x0, y0, x1, y1)

Plot arrow from (x0,y0) to (x1,y1). See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotClose (svgPlot)

Close a SvgPlot object. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotSetForegroundColor (svgPlot, color)

Set foreground color to svgPlot. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load

— Function File: SvgPlotSetLineWidth (svgPlot, width)

Set line width width to svgPlot. See also: SvgPlotNew

See also: svgcanvasload, svgcanvassave, svgcanvas_delete_on_load