首页 > 解决方案 > 如何使用 ggplot2 缩放图形

问题描述

ggplot(data=response, aes(x=beak_size, fill=generation)) 

到目前为止,这是我的代码,我不断得到一个几乎不可读的图形,当我尝试使用基本 RI 制作直方图时,以下代码不断出现此错误:

hist(response$beak_size, col="lightblue",
     main="Graph",
     xlab="Beak Size", ylab="Count")

Error in hist.default(response$beak_size, col = "lightblue", main = "Graph",  : 
  'x' must be numeric

标签: rggplot2

解决方案


使用hist()

hist(as.numeric(response$beak_size), col="lightblue",
     main="Graph",
     xlab="Beak Size", ylab="Count")

如果您的可变测量尺度不是定量的,则应使用barplot().


推荐阅读