library(ggplot2)
library(tidyr)
library(scales)
#faili sisselugemine ja andmete formaadi korrigeerimine
J533=read.csv("PT5-T5.1-J5.1.3.csv",header=TRUE, encoding ="UTF-8")
names(J533)=gsub("\\.", " ", names(J533))
J533=pivot_longer(J533,2:5)
J533$X=as.factor(J533$X)
J533$X=factor(J533$X, levels(J533$X)[order(c(2,1,3,4))])
J533$name=as.factor(J533$name)
J533$name=factor(J533$name, levels(J533$name)[order(c(2,3,1,4))])
#joonis
ggplot(J533)+
geom_col(aes(x=X,y=value,fill=name),width=0.7,pos=position_dodge(0.8))+
theme_minimal()+
scale_fill_manual(values=c("#8fa300","#0069AD","#295200","#1E272E"))+
theme(text = element_text(color="#668080"),axis.text=element_text(color="#668080"))+
scale_y_continuous(limits=c(0,60))+
xlab("")+
ylab("%")+
scale_x_discrete(labels = wrap_format(20))+
theme(legend.title=element_blank(), legend.position = "bottom")+
guides(fill=guide_legend(nrow=2,byrow=TRUE))
