How do I include bar values in a barplot (or other R graphics, where this could be applicable)? To make sure I am clear I am attaching a barplot created with OpenOffice.org which has barplot values written on top of each barplot. -- Donatas Glodenis http://dg.lapas.info
Donatas G. wrote:> How do I include bar values in a barplot (or other R graphics, where this > could be applicable)? > > To make sure I am clear I am attaching a barplot created with OpenOffice.org > which has barplot values written on top of each barplot. >This causes an optical illusion in which the viewer adds some of the heights of the numbers to the heights of the bars. And in general dot charts are greatly preferred to bar plots, not the least because of their reduced ink:information ratio. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University
On Tuesday 07 August 2007 22:09:52 Donatas G. wrote:> How do I include bar values in a barplot (or other R graphics, where this > could be applicable)? > > To make sure I am clear I am attaching a barplot created with > OpenOffice.org which has barplot values written on top of each barplot.Here is the barplot mentioned above: http://dg.lapas.info/wp-content/barplot-with-values.jpg it appeaars that this list does not allow attachments... -- Donatas Glodenis http://dg.lapas.info
See: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/56852.html On 8/7/07, Donatas G. <dgvirtual at akl.lt> wrote:> On Tuesday 07 August 2007 22:09:52 Donatas G. wrote: > > How do I include bar values in a barplot (or other R graphics, where this > > could be applicable)? > > > > To make sure I am clear I am attaching a barplot created with > > OpenOffice.org which has barplot values written on top of each barplot. > > Here is the barplot mentioned above: > http://dg.lapas.info/wp-content/barplot-with-values.jpg > > it appeaars that this list does not allow attachments... > > -- > Donatas Glodenis > http://dg.lapas.info > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. >
Generally adding the numbers to a graph accomplishes 2 things: 1) it acts as an admission that your graph is a failure 2) it converts the graph into a poorly laid out table (with a colorful and distracting background) In general it is better to find an appropriate graph that does convey the information that is intended or if a table is more appropriate, then replace it with a well laid out table (or both). Remember that the role of tables is to look up specific values and the role of graphs is to give a good overview. The books by William Cleveland and Tufte have a lot of good advice on these issues. Before asking how to get R to produce a graph that looks like one from a spreadsheet, you should study: http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html and some of the links from there. You may also want to run the following in R:> library(fortunes) > fortune(120)In general I like OpenOffice, my one main complaint is that when faced with the decision between doing something right or the same way as microsoft, they have not always made the right decision. Hope this gives you something to think about, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at intermountainmail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Donatas G. > Sent: Tuesday, August 07, 2007 1:10 PM > To: r-help at stat.math.ethz.ch > Subject: [R] how to include bar values in a barplot? > > How do I include bar values in a barplot (or other R > graphics, where this could be applicable)? > > To make sure I am clear I am attaching a barplot created with > OpenOffice.org which has barplot values written on top of > each barplot. > > -- > Donatas Glodenis > http://dg.lapas.info > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. >
On Tuesday 07 August 2007 22:09:52 Donatas G. wrote:> How do I include bar values in a barplot (or other R graphics, where this > could be applicable)? > > To make sure I am clear I am attaching a barplot created with > OpenOffice.org which has barplot values written on top of each barplot.After more than two hours search I finally found a solution: http://tolstoy.newcastle.edu.au/R/help/06/05/27286.html and http://tolstoy.newcastle.edu.au/R/help/05/09/12936.html However, what about percentage barcharts, such as this: http://dg.lapas.info/wp-content/barplot-lytys-G07_x_mean.png And maybe somebody knows how to get the legend of the bars in the barchart (again, see the example above)? -- Donatas Glodenis http://dg.lapas.info
On Wednesday 08 August 2007 00:40:56 Donatas G. wrote:> On Tuesday 07 August 2007 22:09:52 Donatas G. wrote: > > How do I include bar values in a barplot (or other R graphics, where this > > could be applicable)? > > > > To make sure I am clear I am attaching a barplot created with > > OpenOffice.org which has barplot values written on top of each barplot. > > After more than two hours search I finally found a solution: > http://tolstoy.newcastle.edu.au/R/help/06/05/27286.htmlHey, the solution happens to be only partiall... If the values are not real numbers, and have a lot of digits after the dot, the graph might become unreadable... see this vals <- c(1,1.1236886,4.77554676,5.3345245,1,1.1236886,4.77554676,5.3345245,5.5345245,5.4345245,1.1236886,4.77554676,5.3345245,1.1236886,4.77554676,5.3345245) names(vals) <- LETTERS[1:16] mp <- barplot(vals, ylim = c(0, 6)) text(mp, vals, labels = vals, pos = 3) Is there any way to round up those numbers? I tried using options(digits=2) , and it does change the display of a table, but it does not influence the barplot... -- Donatas Glodenis http://dg.lapas.info
Do you mean like this? my.values=100000:100005 x <- barplot(my.values, ylim=c(0,110000)) text(x, my.values, labels=my.values, pos=3) It is very bad practice and OOo should have its fingers slapped for perpetuating such a form. --- "Donatas G." <dgvirtual at akl.lt> wrote:> How do I include bar values in a barplot (or other R > graphics, where this > could be applicable)? > > To make sure I am clear I am attaching a barplot > created with OpenOffice.org > which has barplot values written on top of each > barplot. > > -- > Donatas Glodenis > http://dg.lapas.info > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, > reproducible code. >