Output.png from gnuplot is not as good as a number from the command line

I often draw graphs on the gnuplot command line, for example:

 gunuplot> plot sin(x) with linespoints pointtype 3 

and the figure seemed gorgeous.

Today I save the graph in a .png file, for example:

 gnuplot> set term png gnuplot> set output "output.png" gunuplot> plot sin(x) with linespoints pointtype 3 

Then I open output.png with eog in Ubuntu, for example:

 $ eog output.png 

I found that output.png displayed in eog is not as good as a drawing built on the command line.

Why? Do I need to configure some parameters before saving output.png ?

PS

I found that around him, firstly,

 set term postscript set output "output.ps" 

then in linux shell

 $ convert output.ps output.jpg 

This method solves my problem.

+44
gnuplot
Jan 31 2018-12-12T00:
source share
4 answers

The source of your PNG quality problems is most likely the lack of anti-aliasing in the Gnuplot png terminal. Since you are not giving screenshots, I'm not sure what you mean when talking about poor line width, but here is what it looks like for me (on MacOS). This screen shot shows the output from the output from gnuplot:

A plot using gnuplot's native aquaterm output

If we create png using set term png , the lines become β€œjumping” and pixels:

The sine curve, plotted using the png terminal

However, there is a version of the png terminal that uses Cairo libs for rendering, and this makes the output much smoother and more enjoyable. set term pngcairo gives the following result:

The sine curve, plotted using the pngcairo terminal

You can use set terminal to check if this version of the terminal is available. If so, this should save you some conversion work and also provide better image quality than JPG (which is not an ideal format for linear art).

+72
Feb 02 2018-12-12T00:
source share

The default size of the generated gnuplot PNG image with the PNG terminal is 640x480 pixels. This resolution in some cases can lead to "pixel" graphics, which are not as good as those produced on the screen with the default terminal (wxt).

You can change the resolution of the output image using the size parameter:

 set terminal png size <x,y> 

where x and y are the desired number of pixels along the horizontal and vertical axis, respectively. For example:

 set terminal png size 1024,768 

Note that higher resolution images result in a proportionately larger number of files on disk. Alternatively, you can use non-raster terminals such as "post eps" or "pdf" if available on your computer, which can give you high-quality, scalable and (relatively) portable images without a lot of disk space.

+12
Jun 26 '14 at 13:04 on
source share

Alternatively, if you need professional (ready-to-publish) images from gnuplot, you should look at the epslatex terminal. I used it for my dissertations and my work with very good results, with practically no problems with pixelation, portability when converting images to pdf, and almost all the features of Latex.

+8
Jan 31 '14 at 7:34
source share

Comment: A JPEG file is used as an example. You should probably never use JPEG for line graphs unless they have photos as background. JPEG is simply not designed to handle the sharp edges of linear patterns.

+1
Jan 10 '15 at 14:26
source share



All Articles