0

I'm trying to edit my plot title but no matter what I try for whatever reason it won't actually change. Can someone please help me figure out what's going on? I've also tried adding a different theme before my other theme but that just screws everything else up. I'd appreciate any help! I've attached an image of my code and my plot below. As you will see I've set

theme(plot.title = element_text(face = "bold.italic", colour="black", 
      size = 12, hjust = 0.5) 

but the plot is not reflecting any of those edits.

Code

Plot

Peter
  • 11,500
  • 5
  • 21
  • 31
  • 5
    Welcome to Stack Overflow. We cannot read code or data into R from images. Please [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including all code as plain text, and a small representative dataset in a plain text format - for example the output from `dput(G1B2stodenplot)`, if that is not too large. – neilfws Dec 09 '21 at 22:29

1 Answers1

0

Never mind I was able to figure it out by introducing the black and white theme and then editing the theme. See code below:

G1B2stodenplot2 <- ggplot(G1B2stodenplot, aes(x=Drought, y=Average_stomatal_density_of_FOV_area, colour=Locality, shape=Locality, group=Locality, shape=Locality)) + 
    geom_errorbar(aes(ymin=Average_stomatal_density_of_FOV_area-se, ymax=Average_stomatal_density_of_FOV_area+se), colour="black", width=.1, position=pd) +
    geom_line(aes(group=Locality, linetype=Locality), show.legend=FALSE, position=pd) + #makes the different lines connecting dots, adds the lines, removes geom_line legend
     geom_point(aes(group=Locality, shape=Locality), size=4, fill="white", position=pd) + 
    #geom_point(position=pd, size=4, shape=21, fill="white") + #21 is filled circle
    scale_colour_manual(name = "Populations",
                      labels = c("Anderson Dam", "Northern Swanton", "Southern Swanton"),
                      values = c("orange", "blue", "brown4")) +   
    scale_shape_manual(name = "Populations",
                     labels = c("Anderson Dam", "Northern Swanton", "Southern Swanton"),
                     values = c(17, 16, 15)) + #shape numbers
    #labs(title="Evolution & Plasticity in Stomatal Density of"~italic("Collinsia multicolor"), x="Years", y="# / mm^2")+
    ggtitle("Evolution in Stomatal Density of"~italic("Collinsia multicolor"))+
    xlab("Years") +
    ylab("# / mm^2") +
    ylim(25, 40)+ #changes y-axis limits
    xlim("Predrought", "Postdrought")+
    theme_bw()+
    theme(plot.title = element_text(colour = "black", size = 14, face = "bold", hjust = 0.5),
          panel.background = element_rect(fill="white"), # Set plot background to white
          panel.grid.major = element_blank(), #remove grid lines
          panel.grid.minor = element_blank(), #remove gride lines
          #panel.border = element_blank(), #remove plot border
          legend.key  = element_rect(fill = "white"), # Set legend item backgrounds to white
          legend.box.background = element_rect(colour = "black"), #set legend border & color black
          legend.title = element_text(hjust = 0.5, color = "black", size = 10, face = "bold"),
          #axis.line.x = element_line(colour = "black", size = 1),  # Add line to x axis
          #axis.line.y = element_line(colour = "black", size = 1),   # Add line to y axis
          axis.text.x = element_text(face="bold", colour="black", size=10),
          axis.text.y = element_text(face="bold", colour="black", size=10),
          axis.title.x = element_text(colour = "black", size = 12, face = "bold"),
          axis.title.y = element_text(colour = "black", size = 12, face = "bold"),
          axis.ticks.length=unit(-0.25, "cm"), #changes tick mark length
          axis.ticks.margin=unit(0.5, "cm") #changes tick mark in or out of plot
          )
G1B2stodenplot2 
njp
  • 620
  • 1
  • 3
  • 16
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – MD. RAKIB HASAN Dec 13 '21 at 11:53