[R] Scope of Axes

S Ellison S.Ellison at LGCGroup.com
Thu Oct 22 18:54:41 CEST 2015


> fhist<-hist(Simulation,plot=FALSE)
> par(mar=c(6,0,6,6))
> barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray")

i) Unlike hist(), barplot() does not plot at histogram bin boundaries - you'll have noticed that you did not specify locations for the bars and in fact can not do so . There is no simple way of aligning a barplot with particular axis length and locations. But there is a useful example of usig rect() to do the job in ?pairs; look for the USJudgeRatings example and see the panel.hist function there. It should be straightforward to adapt that for horizontal use.

ii) axes= has nothing to do with the plot limits. xlim and ylim control plot limits.  You should set ylim and the top and bottom margins to the same values for both plots.

iii) Your png file includes a barplot with gridlines, so that cannot be the result of the exact command you used above. If you used a different plotting system for the bar plot the alignment would be very hard to guarantee, so stay with base graphics for both.



S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list