DMelt:Plots/Export to Vector Graphics

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member
Contents

Export to vector graphics

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

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

from jhplot  import *
c1 = HPlot("Canvas")
c1.visible()
c1.setAutoRange()
f1 = F1D("2*exp(-x*x/50)+sin(pi*x)/x", -2.0, 5.0)
f1.setPenDash(4)
c1.draw(f1)
c1.export("example.svg")

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 dmelt_batch.sh) method, you can set:

c1.visible(False)

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 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:

More information on this topic is in DMelt books