Wolf, Michael
2004-Sep-24 07:35 UTC
AW: [R] How to improve the quality of curve/line plots?
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". 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
Arne Henningsen
2004-Sep-24 08:01 UTC
AW: [R] How to improve the quality of curve/line plots?
On Friday 24 September 2004 09:35, 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" lineplot. 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".You can increase the linewidth with, e.g.: plot (xval, yval, type="l", lwd=2)> 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!?And you can increase the resolution, e.g.: png( "myplot.png", 1000, 1000 ) Best wishes, Arne> 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-- Arne Henningsen Department of Agricultural Economics University of Kiel Olshausenstr. 40 D-24098 Kiel (Germany) Tel: +49-431-880 4445 Fax: +49-431-880 1397 ahenningsen at agric-econ.uni-kiel.de http://www.uni-kiel.de/agrarpol/ahenningsen/
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". > > 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!?No. The problem is the "small" resolution of your screen. Note that the screen is a bitmap! The graphics are vectorized! So it's a matter of displaying the graphics on your dise, not of generating them. Uwe Ligges> 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
2004-Sep-24 08:11 UTC
AW: [R] How to improve the quality of curve/line plots?
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
I posted a similar question while ago: http://tolstoy.newcastle.edu.au/R/help/04/03/0590.html with not much success. The only replies I recieved were in private, the one i keep in my inbox is: "Is this just a "rasterization" effect? i.e., a conceptually smooth line looks jagged because the screen can only turn on the pixels closest to where the line goes. The example looks smooth when printed right(?)" The reply is that it looks better (although not perfect) when printed or when I use a postscript device. Angel 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". > > 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 > > . >
(Ted Harding)
2004-Sep-24 09:55 UTC
AW: [R] How to improve the quality of curve/line plots?
On 24-Sep-04 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". > > 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!?You might describe it in this way! The fundamental issue is that on screen the display is generated by assigning different colours to each of an array of tiny panels, the "pixels". The actual size of a pixel depends on the hardware, i.e. your monitor, but typically it is of the order of 1/100 inch (i.e. 1/4 mm). This size is quite visible and can give a ragged or "stepped" appearance to things which you might expect to show as smooth curves or lines. This effect is also different between CRT monitors (where the pixel is illuminated by a scanning electon beam) and TFT monitors where each pixel is a physical entity and is activated under electronic control. TFT pixels are more sharply defined then CRT pixels, and have a clearly visible square shape. Thus, for instance, the representation of letters on the screen (e.g. "c" or "C") will also show rough edges if looked at closely. CRT pixels are a bit "fuzzy" at the edges and corners, and so look smoother. When a plot is sent to the screen, the pixel which is turned on is (or should be) the one which is nearest to the mathemtical point in the ideal plot. This inevitably results in a somewhat "broken" appearance such as you describe. The same applies to any bit-mapped representation. One solution for printing purposes is to save the plot in any vector-graphic format (PostScript or Windows Metafile), where lines and curves are mathematically defined and when rendered (on, e.g. a printer which has pixels of the order of 1/1200 inche or 1/300 mm, or smaller) give results which, to the naked eye, look much smoother since the dots are much smaller (also, printer "pixels" are often approximately circles rather than squares). Nevertheless, you can still detect the roughness if you use a strong magnifying glass. On screen, there is a rendering technique called "anti-aliasing". This means that as well as activating a given pixel as above, neighbouring pixels are also activated at lower intensities, so that each "real" pixel is surrounded by a halo of "false" pixels at lower intensity, thereby artifically fuzzing the edges and giving the eye the impression of smoothness. It may be (though I don't know) that this is what Excel does, thereby giving you the impression that the lines are "clean" rather than "dirty". But the fundamental message is that every image which is rendered on a device based on bit-mapping is necessarily "dirty", even if optical trickery gives the opposite impression! Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 [NB: New number!] Date: 24-Sep-04 Time: 10:55:08 ------------------------------ XFMail ------------------------------