简体   繁体   中英

ggplot with extreme values

ggplot条形图

Have two questions -

1.What could be the best way to show / compare extreme values. The T group in the graph has value but no where close to the other groups, M & F

  1. Is the way I can show proper number on the Y axis without having to divide them by 1000s?

Assume a data.frame like the following:

#big values ranging from 10 to 100000 which would normally
#result to 10 not being shown
df <- data.frame(names=letters[1:3], values=c(100000,1000,10))

You can specify a log scale axis so that you can see both big and small values (uses log distance on the y axis) and also specify labels = comma from the scales library inside the scale_y_log10 function to print 'nice' numbers instead of scientific:

See the following:

library(ggplot2)
library(scales) #you need this for labels = comma
ggplot(aes(x=names, y=values), data=df) + geom_bar(stat='identity') + 
  #scale_y_log10 will log scale the y axis
  #labels = comma will create nice numbers
  scale_y_log10(labels = comma)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM