Один из подходов состоит в том, чтобы условно выбрать цвет для заполнить бары:
df$fill <- ifelse(abs(df$RC1) > 0.5, "black", "white") # conditional fill
library(ggplot2)
ggplot(df, aes(x= Parameters, y = RC1)) + geom_col(aes(fill = I(fill)), colour = "black") +
coord_flip() + theme_bw(base_size=10) +
geom_hline(yintercept = 0.5, color = 'black', linetype = "dotted")
# add another geom_hline if you need for - 0.5
![Factor loadings](https://i.stack.imgur.com/9zIFL.png)
данные:
df <- read.table(text = "Parameters RC1 RC2 RC3
NSC.Glucose 0.22 0.97 0.06
NSC.Fructose 0.38 0.57 0.1
NSC.Sucrose 0.13 0.63 0.06
NSC.Starch 0.23 0.72 0.06
Enzyme.INV 0.22 0.97 0.06
Enzyme.SPS 0.62 0.64 0.16
Enzyme.PGM 0.74 0.52 0.43
Enzyme.PFP 0.11 0.97 -0.02
Enzyme.AGP -0.06 0.91 0.2
Enzyme.PGI 0.65 0.73 -0.2
Photosynthesis.Pn 0.12 0.82 0.15
Photosynthesis.Gm 0.02 0.38 0.01
Photosynthesis.Jmax 0.12 0.82 0.15
photosynthesis.Vcmax 0.12 0.82 0.15
gene.FBA 0.26 0.69 -0.03
gene.FBP 0.36 0.69 -0.02
gene.BFII 0.18 -0.78 -0.18
gene.CAB 0.23 0.73 0.05
gene.RuBisCo 0.31 0.75 -0.06
gene.RCA 0.49 0.28 0.07
gene.RPI 0.48 0.26 0.1
gene.PAL 0.43 -0.1 -0.14
gene.PSII 0.28 0.74 0.09
gene.STP 0.64 -0.41 -0.02", header = TRUE , colClasses = c("character", rep("numeric", 3)))