Danke für deinen Versuch.
Es scheint also daran zu liegen, dass ich eine SVG-Datei mit image_read einlesen will?!
Ich bekomme ein super pdf hin: Sobald aber die SVG-Datei als Logo mit deinem Code angehängt wird...
Dein angepasster Code dazu:
Code: Alles auswählen
library(ggplot2)
library(hrbrthemes)
library(scales)
library(Cairo)
library(extrafont)
extrafont::loadfonts()
#font_import()
#loadfonts()
#Dateneingabe
Konz_x <- c(47143480, 4714348, 4714, 2357, 1179, 471)
CT_Wert_y <- c(18.68, 22.595, 33.004, 34.290, 35.369, 35.271)
data.frame(Konz_x, CT_Wert_y)
p <- data.frame(Konz_x, CT_Wert_y)
p
#Model-Erstellung für Formeldarstellung in plot
model <- lm(CT_Wert_y ~ log(Konz_x))
summary(model)
model
eqn <- as.character(as.expression(substitute(italic(y)==a+b*italic(x)*"," ~~ italic(r)^2~ "=" ~ r2,
list(a = format(coef(model) [1], digits = 4), b = format(coef(model)[2], digits = 4), r2 = format(summary(model)$r.squared, digits = 2)
))))
eqn
parse(text = eqn)
#Plot-Erstellung
point <- ggplot(p, aes(x=Konz_x, y=CT_Wert_y))
p <- point + geom_point() + annotation_logticks(sides = "b") + scale_x_log10() + stat_smooth(method=lm, se=0.99, colour="purple") +
labs(title = 'Linearity Plot of FTD-Kit Data',
subtitle = 'Linearity Plot to find Range of Linearity with Coefficient of Determination',
x = 'Copies/ml patient sample',
y = 'Ct-value',
caption = 'Name / Name@Name.de') +
annotate("text", label = eqn, parse = TRUE, x=2600 , y=20.5) +
theme_ipsum() +
theme(plot.title = element_text(color = "#3a4fa7ff"), plot.caption = element_text(color = "#3a4fa7ff", face = 'bold'))
ggsave('cairo.pdf', p, device = cairo_pdf)
library(magick)
tiger <- image_read_svg('/Users/Andreas/Pictures/black-sailing-boat.svg')
plot <- image_read('cairo.pdf')
final_plot <- image_composite( plot, image_scale(tiger, "100"), offset = "+400")
final_plot
image_write(final_plot, "test_final.pdf")