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