[R] barplot -issues with axis and labels not appearing

Jim Lemon drjimlemon at gmail.com
Wed Jul 22 11:20:53 CEST 2015


Hi Pierre,
I get a reasonable plot using the following code:

par(mar=c(6,4,4,2))
barpos<-barplot(unlist(GEP.data2),
 main="Global Portfolio Weights",
 col.main="gray", col=blues9,
 cex.axis=1, ylim=c(-1,1), las=2,
 cex.lab=1, cex=0.8)
axis(1,at=barpos,labels=rep("",8))

For one thing, you don't need the "beside=TRUE" argument as there is
only one vector of values to display. The small value for "cex.axis"
made the tick labels unreadable on my display. If you would like to
have the bar labels horizontal, have a look at the "staxlab" function
in the plotrix package.

Jim


On Tue, Jul 21, 2015 at 10:38 PM, Pierre Micallef
<micallefpierre at hotmail.com> wrote:
> Hi
>
> I am experiencing a few issues with the barplot function.
>
> I have written the following code;
>
>   barplot(as.matrix(GEP.data2), beside=TRUE, main="Global Portfolio Weights", col.main="gray", col=blues9,
>           cex.axis=0.1, ylim=c(-1,1), las=2, cex.lab=1, cex=0.8)
>
>
> where;
>> GEP.data2 =
>   VGSIX.equity VUSTX.equity VGTSX.equity VFISX.equity VTSMX.equity VFITX.equity VEIEX.equity VIPSX.equity
> 1  -0.08645095   0.08991793   0.03548216         0.45         0.45         0.45   -0.1689109   -0.2200382 However i  am having the following issues; (1) neither x or y axis appear on my graph (bars appear as if they are floating)(2) no axis labels are showing up (3) chart title is too high on graph and is being cut off from view Please can you help solve these issues? Thanks Pierre
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list