小编pau*_*lvr的帖子

ggplot 百分比乘以 100

我想使用 ggplot 制作一个在 y 轴上显示百分比的图。这是我使用的数据和代码

data<-"yrs.1.17 yrs.18.44 yrs.45.64 yrs.65.84 yrs.85.
1     4.53     35.12     32.93     22.86    4.57
2     4.01     34.74     34.19     22.71    4.34
3     4.75     33.23     35.19     22.28    4.51
4     4.60     34.04     36.93     20.70    3.56
5     4.80     33.82     37.69     19.97    3.52
6     4.30     35.09     37.08     19.83    3.65
7     3.65     38.08     36.19     19.18    2.85
8     3.72     38.11     36.10     19.22    2.86"

mydata<- read.table(text=data, header=TRUE)


year<-c(2006,2007,2008,2009,2010,2011,2012,2013)
df<-data.frame(year,mydata)
library(ggplot2)
library(reshape2)
library(scales)
newdf<-melt(df,'year')
ggplot(newdf,aes(x=year,y=value,group=variable,color=variable))+ geom_line(size=1)+
scale_x_continuous(breaks=year)+xlab("Year")+scale_y_continuous(labels = percent,limits=c(1,50),breaks=seq(5,50,by=5))+ylab("Age groups")+
geom_point(aes(shape=variable),size=3)+
ggtitle("Age groups of people between 2006 …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

5
推荐指数
1
解决办法
4294
查看次数

标签 统计

ggplot2 ×1

r ×1