0
votes

I try to change the order of the histogram bars manually, but just can't make it happen. Could someone help me out?

I want to make the bars with the following first numbers to be placed next to each other: 1-8-12, 2-7-11, 3-6-10 and 4-5-9.

I also try to change the colors to another palette, without success. I'd appreciate if someone could help out with the right code for this.

enter image description here

dsv <- read.csv("mydata.csv",sep=";",dec=",",header=TRUE,row.names=1)
dsv$Diatomeer <- NULL
tdsv <- t(dsv)
pdsv <- prop.table(as.matrix(tdsv),margin=2)
sum(pdsv)
tpdsv <- pdsv*100 
plotdsv <- melt(tpdsv)
head(plotdsv)
colnames(plotdsv) <- c("Art","Basseng","value")
ggplot(plotdsv,aes(x=Basseng,y=value,ymin=0,ymax=value,fill=Art))+
  geom_bar(stat="identity")+
  theme(axis.text.x=element_text(angle=90))
1
use scale_x_discrete (limits = ...)Bg1850
Finally. Thank you so much! You can't help with the colours as well?metazoa
try scale_fill_gradientBg1850
It works, but the colors are still in a order which make it hard to see the different colors apart. Any tips to how I can make it more specific or the colors more defined/different of each other?metazoa

1 Answers

0
votes

For the colouring, try this

my_pal <- c(RColorBrewer::brewer.pal(9, 'Set1'),
          RColorBrewer::brewer.pal(8, 'Set2'))

later in ggplot add

scale_colour_manual(values=my_pal)