R 通过ggplot将直方图更改为线形图
我需要绘制geom_柱状图,但由于绘制重叠,我希望绘制线性而不是条形图,即x=hp,y=count(百分比)。 有人能帮我找到怎么做吗R 通过ggplot将直方图更改为线形图,r,ggplot2,R,Ggplot2,我需要绘制geom_柱状图,但由于绘制重叠,我希望绘制线性而不是条形图,即x=hp,y=count(百分比)。 有人能帮我找到怎么做吗 library(ggplot2) library(scales) ggplot(mtcars, aes(x=hp)) + geom_histogram(binwidth=5) 我已经做了qplot,但我需要做它在ggplot和百分比 qplot(hp, data = mtcars, geom = "freqpoly", binwidth = 10)
library(ggplot2)
library(scales)
ggplot(mtcars, aes(x=hp)) +
geom_histogram(binwidth=5)
我已经做了qplot,但我需要做它在ggplot和百分比
qplot(hp, data = mtcars, geom = "freqpoly", binwidth = 10)
谢谢您可以使用
geom\u freqpoly
:
library(ggplot2)
library(scales)
ggplot(mtcars, aes(x=hp, y=..count../sum(..count..))) +
geom_freqpoly(binwidth=5) +
scale_y_continuous(labels = percent_format()) +
ylab("Percent")