DMelt:Plots/Export to Vector Graphics

From HandWiki
Limitted access. First login to DataMelt if you are a full DataMelt member. Then login to HandWiki as a user.

Export to vector graphics

Any graphical canvas can be exported to high-quality image files. Publication-quality graphics can be achieved using Vector graphics output supported by DataMelt.

There are several ways to save image canvases to SVG files. For example, use the method "export" of the jhplot.HPlot jhplot.HPlot class.

from jhplot  import *
c1 = HPlot("Canvas")
f1 = F1D("2*exp(-x*x/50)+sin(pi*x)/x", -2.0, 5.0)

This will create SVG image showing the function "2*exp(-x*x/50)+sin(pi*x)/x". The execution of this script will pop-up the canvas itself. If you run this script not inside DataMelt IDE, but using the batch (using method, you can set:


This will quietly generates the file example.svg. How to create EPS and PDF files? Generally, you can do it using the file extensions:

c1.export("example.pdf")  # PDF output file
c1.export("example.eps")  # EPS output file

You can also export files to raster formats, using the extensions ".png" and ".jpg". This will create good-quality images with support of transparency. But you cannot resize such plots.

Creating EPS and PDF files

For inclusion of files generated by DataMelt to Software:LaTeX documents, you should make EPS or PDF files. The quality of figures for publications should be very high, and file sizes should be optimized. Therefore, the recommendation is to create first SVG file, and then convert it to EPS or PDF. It is also recommended to do the same if you need a high-quality PNG image.

This can be done on Linux and MAC OS computers using external programs. For example, this is an example of creating high-quality PDF and EPS files from SVG format:

Native creation of EPS and PDF

You can further increase the quality of output images when using DataMelt directly without external programs. In this approach, you can create publishable-quality EPS and PDF images on Windows. A high-quality, optimized PDF or EPS file will be created directly by the Jython/Java program where graphics canvas is defined.

Here is an example of making EPS file from SVG using DMelt Java library: