if(!require(remotes)) install.packages("readr")
library (readr)
github="https://raw.githubusercontent.com/agronomy4future/raw_data_practice/refs/heads/main/SOC.csv"
df=data.frame(read_csv(url(github),show_col_types= FALSE))
print(head(df, 5))
Column Row SOC
1 1 1 1.45
2 2 1 1.60
3 3 1 2.34
4 4 1 2.20
5 5 1 1.80
.
.
.
ggplot(df, aes(x=Column, y=Row, fill=SOC)) +
geom_tile(color="white") +
geom_text(aes(label=round(SOC, 1)), color="black", size=3) +
scale_x_continuous(breaks=1:19) +
scale_y_continuous(breaks=1:13) +
scale_fill_gradientn(
colours=colorRampPalette(brewer.pal(9, "Blues"))(100),
limits=c(0, 4), breaks=seq(0, 4, by=1), name="SOC", na.value="white") +
labs(x="Row", y="Column") +
theme_classic(base_size=15) +
theme(legend.position="right",
legend.title= element_text(size=12),
legend.key.size=unit(0.5,'cm'),
legend.key=element_rect(color=alpha("white",.05), fill=alpha("white",.05)),
legend.text=element_text(size=12),
legend.background=element_rect(fill=alpha("white",.05)),
panel.grid=element_blank(),
panel.border=element_rect(color="black", fill=NA, linewidth=0.5),
axis.line=element_line(linewidth=0.5, colour="black"))