I am using the gap.barplot() function from plotrix, and I've been having a problem when some values are very small. Starting with the following dataframe:
test.df <- data.frame(
perc = c(2.5,7.5,12.5,17.5,22.5,27.5,32.5,37.5,42.5,47.5,52.5,57.5,62.5,67.5,72.5,77.5,82.5,87.5,92.5,97.5),
count = c(143649,30872,17444,11333,7513,5257,3677,2795,1976,1530,1022,916,862,985,808,339,59,2,1,1)
)
If I create a gapped bar plot as follows:
library(plotrix)
gap.barplot(test.df$count, gap=c(38000,136000), xaxlab=test.df$perc, xtics=test.df$perc, ytics=c(0:30)*5000, col="white", las=1)
it comes out looking fine.
However, if I try to divide the "count" values by 1000, using the following code:
gap.barplot(test.df$count/1000, gap=c(38,136), xaxlab=test.df$perc, xtics=test.df$perc, ytics=c(0:30)*5, col="white", las=1)
the bars are not anchored at 0.
All "count" values greater than 3000 (or 3 on the new scale) are downward pointing even though they are greater than zero. For some reason the bars are being anchored at 3 rather than 0. Does anyone know why this would happen and what I can do to fix it?