Voici un exemple de création et de sauvegarde dans un fichier png de la courbe représentative d’une fonction.
library(latex2exp)
#############################################
# debut image
#
png( "image.png", width = 640, height = 400 )
a=-2
b=5
f = function(x) {
return(x^2)
}
x = a+ c(0:100)/100*(b-a) ;
y = f(x)
plot(x, y,
xlim=c(a,b),
axes=FALSE,
panel.first = grid(),
xlab=TeX("Courbe de f(x)=x^2"),
ylab=NA,
type="l",
lwd=2,
col="red")
axis(1,pos=0)
axis(2,pos=0,las=2)
points(2,50,pch=4)
xnom = 3
text(xnom,f(xnom),TeX("$(C_f)$"),pos=1,cex=1.5,col="red",offset=1.5)
dev.off()
#
#fin image
#############################################