library(ggplot2)
library(tidyr)
#faili sisselugemine ja andmete formaadi korrigeerimine
J348=read.csv2("PT3-T3.4-J3.4.8.csv",header=TRUE, encoding ="UTF-8")
names(J348)=gsub("\\.", " ", names(J348))
J348=pivot_longer(J348,2:9)
J348$value=as.numeric(J348$value)
J348$Aasta=as.factor(J348$Aasta)
J348$Aasta=factor(J348$Aasta,levels(J348$Aasta)[order(c(2,1))])
J348$name=as.factor(J348$name)
J348$name=factor(J348$name,levels(J348$name)[order(c(3,1,2,4,5,6,8,7))])
#joonis
ggplot(J348)+
geom_col(aes(x=name,y=value,fill=Aasta),pos=position_dodge(0.7),width=0.7)+
facet_wrap(Tööliik~.)+
coord_flip()+
theme_minimal()+
scale_fill_manual(values=c("#634988","#6666CC"),breaks=c("2019","2021"))+
theme(strip.text.x=element_text(color="#668080"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
scale_y_continuous(breaks=seq(0,80,10))+
theme(legend.position = "bottom")+
theme(legend.title = element_blank())+
xlab("")+
ylab("%")
