AW: [R] How to improve the quality of curve/line plots?
Roger Bivand
Roger.Bivand at nhh.no
Fri Sep 24 10:11:29 CEST 2004
On Fri, 24 Sep 2004, Wolf, Michael wrote:
> Thanks for the tip using a smoothing technique before plotiing in order
> to get a curve instead of a line connecting the observations.
>
> But that's not the solution for my main problem with the "unclean" line
> plot. In order to show my problem let's take this simple example:
>
> > xval <- c(1, 2, 3, 4, 5, 6, 7, 8)
> > yval <- c(10, 30, 40, 50, 70, 90, 100, 110)
> > plot (xval, yval, type="l")
>
> If you look to the result in the graphic window you will see that the
> line seems to exist of many points between the observations; e. g.
> between xval=1 and xval=2 the line contains 8 or more sublines. Perhaps,
> you can also observe a break of the line at xval=4. That's what I call
> an "unclean line".
I think you are confusing yourself by mistaking what you "see" on a
particular platform (OS, screen hardware, drivers, resolution) and the
underlying model. The underlying model is vector graphics, so your first
line segment is represented by approximations to lines on raster devices,
like computer screens or PNG, but is still vector when the output device
is vector.
> postscript()
> plot (xval, yval, type="l", axes=FALSE, xlab="", ylab="")
> dev.off()
and Rplots.ps contains:
%%Page: 1 1
bp
77.04 91.44 793.65 518.24 cl
0 0 0 rgb
0.75 setlinewidth
[] 0 setdash
1 setlinecap
1 setlinejoin
10.00 setmiterlimit
np
103.58 107.25 m
94.79 79.03 l
94.79 39.52 l
94.79 39.52 l
94.79 79.04 l
94.79 79.03 l
94.79 39.52 l
94.79 39.52 l
o
18.00 18.00 823.89 577.28 cl
ep
%%Trailer
%%Pages: 1
which is a vector representation in the scale of the output device (move
to (103.58 107.25), draw a line to (94.79 79.03) from here, ...). But if
you display the postscript file on a screen, it has to be rasterised - it
has to be rasterised to be printed too, but most printers have much higher
resolution than screens. Note that "exact appearance" is just what the
second word says, "appearance". For making vector graphics output, you may
find the postscript and pdf devices useful, and I think Windows metafiles
on that platform (reading src/gnuwin32/graphapp/metafile.c shows how much
work is needed to get graphics to work!).
>
> Even if you try to export the plot with the png command you can observe
> the same phenomenon. The line has not an exact appearance like Excel
> diagram plots. If there are no other techniques to get better line plots
> it seems to be a problem of the graphic output!?
>
> Michael Wolf
>
> -----UrsprÃ¼ngliche Nachricht-----
> Von: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de]
> Gesendet: Freitag, 24. September 2004 09:00
> An: Wolf, Michael
> Cc: r-help at stat.math.ethz.ch
> Betreff: Re: [R] How to improve the quality of curve/line plots?
>
> Wolf, Michael wrote:
>
> > Dear list,
> >
> > I'm using the windows version of R. When plotting a curve or a line for time series with annual data , e. g. GDP growth 1991-2003, the line seems to exist of a lot of smaller lines. Printing the results the curves and lines seems to be "unclean" (because of using small resolution bitmaps?). Comparing the result of R with the same results of Excel the lines in excel seems to havve a higher qualitiy. In Excel you also can produce curves instead of lines.
> >
> > Are there any possibilities how to improve the quality of the plots in R? How can R be influenced to plot "clean" lines with a higher resolution on the screen (I think it's not a question of the pdf- or png command.). Perhaps, it's a problem of the graphical possibilites of R because the most line plots which can be seen on the web have these problems.
>
> Can you specify an example please? I cannot remember any "unclean" plot.
> In particular, no bitmaps are used to render graphics in R.
>
> What I guess is that you have a line plot and each observation is connected with the subsequent one by a line. If you want to smooth it (and you think smoothing is appropriate here), you have to apply a smoothing technique before plotting.
>
> Uwe Ligges
>
>
> > Thanks,
> >
> > Dr. Michael Wolf
> > Bezirksregierung MÃ¼nster
> > Dezernat 61
> > Domplatz 1-3 48161 MÃ¼nster
> > Tel.: ++ 49 (02 51) / 4 11 - 17 95
> > Fax.: ++ 49 (02 51) / 4 11 - 8 17 95
> > E-Mail: michael.wolf at bezreg-muenster.nrw.de
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list