0
votes

I'm plotting with ggplot with the subsets of some data for ggplot to work with. I have written out 2 of the data I want to plot

data link https://drive.google.com/drive/folders/1D7Z6mV3-2Sm3KK_w1s5VNyg-imDCTeBe?usp=sharing

But the problem is my ggplot is not updating the values in the plot, so the new plot generated although have different titles but the values are exactly the same as the old one.

I have tried to restarted the R but it doesnt solve the problem.

I have assigned a variable to d<- ggplot(data)

And I can see d is correctly reflecting the new data loaded, and the actually plot when I print it will update the ggtitle, so the plotting itself wasnt dead. Just for some reason whatever data I'm providing, the actual plot is always the same

library(ggplot2)
library(wesanderson)
d<-ggplot(C1.PDB)
pal <- wes_palette("Zissou1", 50, type = "continuous")

m <-d+
  geom_tile(aes(x=Combination, y=Drug_dose, fill=Avg.percent))+
  geom_text(aes(x=Combination, y=Drug_dose,label=Avg.percent), size=3)+
  scale_fill_gradientn(colors=pal)+
  theme(legend.text = element_text(size=10, face="bold", color = "black"))+
  theme(axis.text.x = element_text(size = 15,  face="bold", color = "black")) +
  theme(axis.text.y = element_text(size = 9,  face="bold", color = "black")) +
  theme(axis.title.x = element_text(size = 15,  face="bold", color = "black", vjust = 3))+
  theme(axis.title.y = element_text(size = 15,  face="bold", color = "black", hjust = 0.5))+
  theme(plot.title = element_text(size = 16))+
  theme(strip.text.y  = element_text(size = 10, face = "bold", color = "black"))+
  scale_x_discrete(position ="top") +
  xlab("Combination added")+
  ylab("Treatments in the screen")+
  ggtitle("Cluster 1 Enriched in PDB response")


  print(m)
1

1 Answers

0
votes

This works for me. Are you loading in your two dataframes from separate .csv files?

library(ggplot2)
library(wesanderson)

d <- sample.data #From your googledrive

pal <- wes_palette("Zissou1", 50, type = "continuous")
m <-ggplot (data=d)+
  geom_tile(aes(x=Combination, y=Drug_dose, fill=Avg.percent))+
  geom_text(aes(x=Combination, y=Drug_dose,label=Avg.percent), size=3)+
  scale_fill_gradientn(colors=pal)+
  theme(legend.text = element_text(size=10, face="bold", color = "black"))+
  theme(axis.text.x = element_text(size = 15,  face="bold", color = "black")) +
  theme(axis.text.y = element_text(size = 9,  face="bold", color = "black")) +
  theme(axis.title.x = element_text(size = 15,  face="bold", color = "black", vjust = 3))+
  theme(axis.title.y = element_text(size = 15,  face="bold", color = "black", hjust = 0.5))+
  theme(plot.title = element_text(size = 16))+
  theme(strip.text.y  = element_text(size = 10, face = "bold", color = "black"))+
  scale_x_discrete(position ="top") +
  xlab("Combination added")+
  ylab("Treatments in the screen")+
  ggtitle("Cluster 1 Enriched in PDB response")
m