How to shade columns for dataframe in ggplot that has 2 dataframes?
1
1
Entering edit mode
2.2 years ago
Amr ▴ 180

I did ggplot2 graph on R, the data is combined 2 dataframes, the plot has many 2 columns with same color each column representing each dataframe, the problem is each 2 columns for 2 dataframes has same colors but outlined with thin color, how to shade the data for one dataframe so that both same colors but one shaded one not shaded ?

df$Cell_lines = 'cell_one'
data2$Cell_lines = 'cell_two'
df3=rbind(df,data2)
ggplot(df3, aes(x=Variant_Classification, y=Number_of_Genes,col =Cell_lines,fill = Variant_Classification)) +
  geom_bar(stat="identity",position = 'dodge')  + theme_minimal() +  labs(title ="cell_one vs cell_two")+ 
  theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank())
ggplot2 R • 891 views
ADD COMMENT
0
Entering edit mode

Provide an example of what your code generates and what you'd like it to generate. You'll get much quicker help that way.

ADD REPLY
0
Entering edit mode

The plot for example has 6 columns, 3 for every dataframe, 2 red, 2 blue, 2 purple, one red outlined with green for dataframe1 and one red outlined with yellow for dataframe 2, one blue outlined with green for dataframe 1 and one blue outlined with yellow for dataframe 2, etc... its not clear like that so I want to make it one red and one red but shaded with black, one blue and one blue shaded with black etc..... in case if you have different idea, its good also. Thanks

ADD REPLY
1
Entering edit mode
2.2 years ago
Amr ▴ 180

This code change the color and thickness of the border for better visualization:

df3 = rbind(df,data2)

ggplot(df3,aes(x=Variant_Classification,y=Number_of_Genes,col=Cell_lines,fill=Variant_Classification)) +
  geom_bar(stat="identity",position='dodge',size =1)+
  theme_minimal()+
  labs(title="cell_twovscell_one")+
  theme(axis.title.x=element_blank(),axis.text.x=element_blank(),axis.ticks.x=element_blank()) + 
  scale_color_manual(values = c("cell_one" = "red","cell_two"="black"))
ADD COMMENT

Login before adding your answer.

Traffic: 2884 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6