How to add the structure of a molecule to a graph in R using either SMILES or an image?

I want to add a molecule of the structure of 4-aminobenzoic acid to my graph in R. The graph shows the infrared spectrum of the indicated molecule. Is there a way to add this using the code SMILESthat will be O=C(O)c1ccc(N)cc1, or can I add it as an image, which can be found here (edited below). I wrote the following script:

par(family="mono", font.axis=1)
data <- read.table("D13-4-aminobenzoic_acid.asc")
x <- data[,1]
y <- data[,2]
x1 <- x[rev(order(x))] # reverse order x

plot(x1,y, type="n", xlim=rev(range(x)),  
     axes=FALSE,
     xlab=expression(paste("Wavelength [", cm^-1,"]")),
     ylab="Transmittance [%]"
     )

lines(x1, y, col="firebrick")

axis(1, at=seq(500,4000,250))
axis(2, at=seq(40,100,10), xpd=T)

The .asc file can be found here . I would like the molecule to be located in the lower left corner, since there is the most free space.

Image reduced by 85%:

enter image description here

+4
source share
1 answer

png grid:

library(png)
library(grid)
img <- readPNG("img.png")
grid.raster(img, x=.15, y=.25, width=.3, hjust=0, vjust=0)

enter image description here

?grid.raster . x y , , width height .

+2

All Articles