Hi everyone, I'm typing an exam using Knitr and documentclass(exam): everything works fine, except that plots are not shown. All I get is a dark rectangle instead of the plot. I used basic plots that work in documentclass(article), taken from there: Minimal examples - Examples for Rnw, Markdown, HTML and LaTeX - Yihui Xie | 谢益辉. I provide a MWE below. ggplot does not work either. Any thoughts ? Thank you !
% \documentclass[addpoints,12pt]{exam}
\documentclass[addpoints,12pt,answers]{exam}
\usepackage[left=1.5cm,right=1.5cm,top=1.5cm,bottom=1.8cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{amsmath, amsfonts, amssymb, amsthm}
\usepackage{multirow}
\usepackage{setspace}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage{epsfig}
\usepackage{float}
\usepackage{subfig}
%\usepackage{url}
% Allow linebreak in footnote for url's
\usepackage[hyphens]{url}
%\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}
\renewcommand\questionlabel{\textbf{\thequestion.}}
\renewcommand\partlabel{\textbf{\thepartno.}}
\renewcommand\subpartlabel{\textbf{\thesubpart.}}
\renewcommand\thepartno{\thequestion.\alph{partno}}
\renewcommand\thesubpart{\thepartno.\roman{subpart}}
\pagestyle{headandfoot}
\footer{}{Page \thepage\ / \numpages}{}
%\usepackage[hyphens,spaces,obeyspaces]{url}
%\urldef{\footurl}\url{http://www.this-is-a-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-very-long.url/}
\usepackage[colorlinks]{hyperref} % optional
\begin{document}
\begin{center}
\fbox{\fbox{\parbox{5.5in}{\centering
Exam}}}
\end{center}
Exam graded over \numpoints\ points with \numbonuspoints\ bonus point(s).
\begin{questions}
\section{Random questions}
\question[1] Who are you ?
\begin{solution}
Mary Poppins
\end{solution}
\question[1] Can you do plots ?
\begin{solution}
<>=
set.seed(1121)
(x=rnorm(20))
mean(x);var(x)
@
<<boring-plots, fig.width=4, fig.height=4, out.width='.4\linewidth'>>=
two plots side by side (option fig.show='hold')
par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3,las=1)
boxplot(x)
hist(x,main='')
@
\end{solution}
\end{questions}
\end{document}