Problem with geom_histogram

The code works fine up until the plot. The problem with the plot is that there are spaces between each column and I don't want that. To better understand what I am trying to do, I want to make a depth-percent plot where on the y axis I have sand-silt-clay(%) Below I enclose an image of the histogram, as well as the code I used to create it. I hope that the image can be displayed (I used the upload function of the Rstudio community, I don't know how to upload an image).

Sand-Silt-Clay-Histogram

library(readxl)

setwd("C:/Users/30693/Desktop/Μεταπτυχιακό 2019-2021/Διπλωματική 2019-2021/Διπλωματική 2019-2021 Λουσοί/Dionisis")

Lousoi_SM=readxl::read_xlsx("Lousoi SM.xlsx")

library(ggplot2)
library(tidyr)
library(dplyr)
mgroup=group_by(Lousoi_SM,Mean)
msum=summarise(mgroup,Sand,Silt,Clay)

msum_long=pivot_longer(msum,col=2:4)

ggplot()+
geom_histogram(data =msum_long,aes(x=Mean,y=value,fill=name),
stat = "identity")

Are you looking for something like this?

library(ggplot2)
DF <- data.frame(Mean=rep(c(1,2,3,4),each=3),Group=c(rep(c("A","B","C"),4)),
                 Value=c(0.2,0.4,0.4,0.1,0.6,0.3,0.3,0.3,0.4,0.4,0.4,0.2))
ggplot(DF,aes(x=Mean,y=Value,fill=Group))+geom_col(width = 1)

Created on 2020-12-12 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.