Hello,
If someone can please help me change the position (name) of the bars, like if i can move them inside the plot so that i will have more space for the image and also how i can change the color for negative bars.
Here is my code:
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.0.4
df <- read.csv("F:/Chapter2_Figures/penalty_lift.csv")
colnames(df)[1] = "Attribute"
colnames(df)[2] = "Score"
df
#> Attribute Score
#> 1 Cookedpotato_F 2.035
#> 2 Cookedpotato_A 1.703
#> 3 Smooth_T 1.199
#> 4 Moist_T 0.853
#> 5 Dense_T -0.378
#> 6 Dry_T -0.848
#> 7 Mealy_T -1.017
#> 8 Rawpotato_A -1.130
#> 9 Rawpotato_F -1.567
df$Attribute <- factor(df$Attribute, levels = c("Rawpotato_F", "Rawpotato_A",
"Mealy_T", "Dry_T",
"Dense_T", "Moist_T", "Smooth_T",
"Cookedpotato_A", "Cookedpotato_F"))
ggplot(df, aes(x=Attribute, y=Score)) +
geom_bar(stat="identity") + coord_flip()
Created on 2021-03-27 by the reprex package (v1.0.0)