Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Poor SVG quality compared to TIFF

Tags:

r

svg

graphics

I have a filled.contour plot that I would like to save as SVG (or EPS) for publication. However I see that the quality of the SVG is significantly worse than that of the TIFF. The plot in the SVG file appears to have some kinds of white boxes/lines/rectangles which do not appear when I save the file in TIFF format. In the TIFF format the color transitions are much smoother and the white rectangles do not appear

Is there anyway to avoid this? I've tried Linux and Mac, getting similar results

Below is the TIFF file and a screenshot of the SVG file that shows the problem.

TIFFSVG screenshot

The code to produce the plots is the following:

x <- 1:5
y <- 1:5
z <- matrix(outer(x,y,"+"),nrow=5)
filled.contour(x,y,z)
filled.contour(x,y,z,color.palette=rainbow)
z2 <- z
z2[5,5] <- Inf
filled.contour(x,y,z2,col=rainbow(100),nlevels=100)
like image 397
ECII Avatar asked Jan 06 '13 15:01

ECII


People also ask

Is SVG better than TIFF?

When printing or publishing commercial or professional work, use TIFF. For designs that require the use of photos that require transparency, PNG is recommended. For web designers and graphics artists who work with responsive websites, SVG is the preferred format.

Is TIFF the best format?

TIFFs are a good choice if you're looking for high resolution, layering, transparency, and flexibility between lossy and lossless compression. They can also function as a container for other file types.

Is TIFF a lossless format?

TIFF is lossless, so there is no degradation associated with saving a TIFF file. Do NOT use TIFF for web images. They produce big files, and more importantly, most web browsers will not display TIFFs.

Why is TIFF a good file format?

Predominantly lossless compression means TIFF files retain the original image's detail and color depth — perfect for high-quality professional photos. Their impressive detail means TIFFs are ideal for high-resolution scans, such as backing up your handmade artwork and personal documents.


1 Answers

Believe it or not this is an anti-aliasing artifact.

http://r.789695.n4.nabble.com/Suppressing-internal-grid-in-filled-contour-td867081.html

On linux I can reproduce your problem, but when I pass the exact same file created in linux, into a windows OS virtual machine I have running - the SVG image appears fine, so it's a problem of the viewing software and anti-aliasing settings, not the R output.

I hope this solves your problem.

like image 162
rmounce Avatar answered Oct 04 '22 15:10

rmounce