[R] Change the scale on a barplot's y axis

Jim Lemon jim at bitwrit.com.au
Sun Feb 28 11:22:08 CET 2010


On 02/28/2010 11:44 AM, Thomas Levine wrote:
> I have grades data. I read them from a csv in letter-grade format. I
> then converted them to levels
>
> levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-')
>
> And then to numbers
>
> grades$gp=grades$grade
> levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)
> grades$gp=as.numeric(as.character(grades$gp))
>
> And I'm plotting them in a barplot
>
> barplot(gp[order(gp)],width=n[order(gp)],ylab="Class Median
> Grade",xlab="Class, scaled to number of students in the
> class",main="Class Median Grades for Cornell University weighted by
> class size")
>
> I would like to change the scale on the bar graph such that it reads
>
> c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-')
>
> in the locations
>
> c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)
>
Hi Tom,
You can do this directly using the height.at and height.lab arguments in 
the barp function in the plotrix package.

Jim



More information about the R-help mailing list