Closed rccline closed 3 years ago
You need to load the ggtext package.
It seems to have something to do with reading the jpg file.
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.0.2
library(markdown)
library(ggtext)
#> Warning: package 'ggtext' was built under R version 4.0.2
library(jpeg)
set.seed(123)
myd<- expand.grid('cat' = LETTERS[1:5], 'cond'= c(F,T), 'phase' = c("Interphase", "Prophase", "Metaphase", "Anaphase", "Telophase"))
myd$value <- floor((rnorm(nrow(myd)))*100)
myd$value[myd$value < 0] <- 0
labels <- jpeg::readJPEG(c(
Interphase = "<img src=' interphase.jpg' width='50' /><br>Interphase",
Prophase = "<img src=' prophase.jpg' width='50' /><br>Prophase",
Metaphase = "<img src=' metaphase.jpg' width='50' /><br>Metaphase",
Anaphase = "<img src=' anaphase.jpg' width='50' /><br>Anaphase",
Telophase = "<img src=' telophase.jpg' width='50' /><br>Telophase"
))
#> Error in jpeg::readJPEG(c(Interphase = "<img src=' interphase.jpg' width='50' /><br>Interphase", : unable to open <img src=' interphase.jpg' width='50' /><br>Interphase
ggplot(myd, aes(phase, value, fill= cat))+
geom_col(position = "dodge") +
scale_x_discrete(name=NULL, labels=labels) +
theme(axis.text.x = element_markdown(lineheight = 1.2))
Created on 2020-09-25 by the reprex package (v0.3.0)
I have run the code suggested on stackoverflow: https://stackoverflow.com/questions/14070953/photo-alignment-with-graph-in-r Images do show up when using the stackoverflow code chunk, but the images are not separated as they appear in the stackoverflow content but are all contiguous. When running the ggtext code chunk, the images are black with Error message "object is not supported." The library markdown is loaded but R could not find element_markdown object.
Brief description of the problem or desired feature.