[R] Fwd: how to add value on the bar ploted by barplot()

David Winsemius dwinsemius at comcast.net
Tue Jun 2 14:20:13 CEST 2009


This is the trivial modification to the example on the help page that  
I was thinking of.

#the example code
   mp <- barplot(VADeaths) # default
   tot <- colMeans(VADeaths)
   text(mp, tot + 3, format(tot), xpd = TRUE, col = "blue")
#the modification
   tot <- colSums(VADeaths)
   text(mp, tot + 3, format(tot), xpd = TRUE, col = "red")

You can learn quite a bit by running the examples on graphics pages.

-- 
David

On Jun 2, 2009, at 12:08 AM, Xiaogang Yang wrote:

> ---------- Forwarded message ----------
> From: Xiaogang Yang <gavinxyang at gmail.com>
> Date: Mon, Jun 1, 2009 at 9:02 PM
> Subject: Re: [R] how to add value on the bar ploted by barplot()
> To: David Winsemius <dwinsemius at comcast.net>
>
>
> I mean I have bar in my plot graph, but I want add the bar real  
> value at top
> of it.
>
> On Mon, Jun 1, 2009 at 8:46 PM, David Winsemius <dwinsemius at comcast.net 
> >wrote:
>
>>
>> On Jun 1, 2009, at 11:21 PM, Xiaogang Yang wrote:
>>
>> how to add value on the bar ploted by barplot()?
>>>
>>
>> Depending on what you really mean, possibly:
>>
>> ?barplot
>> ?text  # there _is_ a worked example on the barplot help page.
>>      # true, it does put the labels above the bars, but the  
>> modification
>> would be trivial.
>> # or
>> ?addtable2plot {in package plotrix}
>>
>>>
>>> and the axis label is too big, anyone know how to change their  
>>> font ,
>>> thanks
>>>
>>
>> ?barplot   # again ...  barplots help page seems quite clear
>>
>>     cex.names = 0.5    # or a number less than one of your choice
>>
>> --
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>>
>
>
> -- 
> Xiaogang Yang
> Sensorweb Research Laboratory
> http://sensorweb.vancouver.wsu.edu/
> Washington State University Vancouver
>
>
>
> -- 
> Xiaogang Yang
> Sensorweb Research Laboratory
> http://sensorweb.vancouver.wsu.edu/
> Washington State University Vancouver
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list