0
votes

Who is the fastest, smartest R user out there??? Easy fix for pros!

I am creating a horizontal barplot and displaying results from traits as a percentile. The industry I work in has the 100th percentile as the lowest and zero the highest. So that is no problem plotting that as you can see with my current command: barplot(mydata$Percentile, names.arg=mydata$Trait,horiz=T,las=1,xlim=c(100,0),base=50) abline(v=50, lty=2) Current version

Currently I have the 100th percentile on left and zero on right. The bars on the plot however come from the right hand side of the plot.

PROBLEM: I would like them to start from 50. For what I am looking to do please see the picture attached from a MATLAB example where they have set the base value at 25. MATLAB example

1

1 Answers

0
votes

One possibility to solve this is to subtract 50 from your values and plot this without axis.than you adapted your axis:

values <- c(100, 10, 55, 30, 120) 
barplot(values-50, horiz=T, axes=F)
axis(side=1, labels=seq(0,120,20), at=seq(0,120,20)-50, xpd=T) 

ps: I guess your first lines, the opening, prevent a lot of people to answer.