0

I am trying to generate a line chart where different genes have been introduced via plasmids into a strain.

The plasmid name needs to be in standard text but the gene in italics for example I would like my legend to read ""pALC2073::clfA.

I have the genes italicised correctly in excel but the formatting is lost on input into Rstudio. My basic script is:

ggplot(subset(Fg1, Strain %in% c("pALC2073", "pALC2073::clfA")), 
       aes(x=conc, y=A570, colour=Strain, shape=Strain))+
  geom_line(cex=1)+
  geom_point(cex=4)+
  theme_classic(base_size = 22)+
  theme(legend.position="right")+
  scale_colour_brewer(palette = "Set1", labels=c("pALC2073", "pALC2073::clfA"))

I also want only one legend for shape and colour.

An example dataset would look like: Example Data

Thank you for helping!

  • Welcome to SO! To help us to help you would you mind sharing [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. To share your data, you could type `dput(NAME_OF_DATASET)` into the console and copy & paste the output starting with `structure(....` into your post. If your dataset has a lot of observations you could do e.g. `dput(head(NAME_OF_DATASET, 10))` for the first ten rows of data. – stefan Mar 18 '22 at 19:10
  • ... this said. To get only one legend try with `scale_shape_discrete(labels=c("pALC2073", "pALC2073::clfA")`, i.e. set the same labels for the shape legend. To solve your formatting issue you could have a look at the [ggtext](https://wilkelab.org/ggtext/) package or look on SO for questions related to ggtext. – stefan Mar 18 '22 at 19:12
  • Hi, thanks I cannot make ggtext work with my ggplot. I would normally import in a data set like this one: Strain Conc Absorbance pALC 0 0 pALC 1 0.1 pALC 2 0.1 pALC 3 0.1 pALC::clfA 0 0 pALC::clfA 1 1 pALC::clfA 2 2 pALC::clfA 3 4 Thanks, – Sara Henderson Mar 21 '22 at 11:25

0 Answers0