This is (an extract) of a beamer presentation I have done for the same topic you are asking.
Note, however, that:
- this is quite advanced TikZ/
pgfplots
usage; I advise you to start with the pgfplots
and TikZ (and if you need it, circuitikz
) tutorials before digging into this code;
- this is a
beamer
presentation, so there is the added complexity of the overlays to obtain the graph construction step-by-step; again, there are very nice tutorials around for beamer too;
- yes, the learning curve of these tools is steep, so if you want to avoid frustration, follow the tutorial path (or give up and use some other tool 😉);
- the Ebers-Moll curve is fake. The real one is too steep a) to stay into the math limits of
pgfplots
and b) to produce anything really readable (reality is hard...);
- I am not sure all the preamble is really needed, I trimmed this down from a big presentation.
So, the code is here. I use styles a lot to avoid repeating myself.
%%%
\documentclass[10pt,
,t %% top by default
,aspectratio=169 %%
,fleqn % left aligned equations
]{beamer}
\usepackage[T1]{fontenc}
%%%
\usepackage{mathtools}
%% siunitx setup
\usepackage{upgreek}
\usepackage{textcomp}
\renewcommand{\textmu}{\ensuremath{\upmu}}
\renewcommand{\textohm}{\ensuremath{\Upomega}}
\usepackage{siunitx}
\sisetup{detect-all, retain-explicit-plus, range-phrase= --,
exponent-product=\cdot, per-mode=symbol}
\usepackage{pgfplots}\pgfplotsset{compat=1.15}
\usetikzlibrary{calc, intersections, fit, arrows.meta,
backgrounds, tikzmark, overlay-beamer-styles}
% circuits
\usepackage[siunitx, RPvoltages]{circuitikz}
\ctikzsetstyle{romano}
\tikzset{>=Stealth}
%
\colorlet{darkgreen}{green!50!black}
\colorlet{darkblue}{blue!50!black}
%
%% common macros here: subscript D is too big for my tastes
\newcommand{\vD}{v_{\scriptscriptstyle D}}
\newcommand{\VDQ}{V_{DQ}}
\newcommand{\vDtot}{v_{\scriptscriptstyle D\mathrm{tot}}}
\newcommand{\iD}{i_{\scriptscriptstyle D}}
\newcommand{\IDQ}{I_{DQ}}
\newcommand{\iDtot}{i_{\scriptscriptstyle D\mathrm{tot}}}
\newcommand{\eq}{=}%not needed in recent circuitikz
% from https://tex.stackexchange.com/a/34243/38080
\newcommand{\openfrac}[3][4pt]{\genfrac{}{}{}{}{%
\raisebox{#1}{$#2$}}{\raisebox{-#1}{$#3$}}}
%% presentation data starts here
%%
\begin{document}
\begin{frame}[label=superpdiodo]
\frametitle{Diode small signal}
\begin{columns}[onlytextwidth, T]
\begin{column}{.38\linewidth}
\begin{circuitikz}[scale=0.9, transform shape, ]
\draw (0,0) to[sV, v<=$v_s(t)\eq\Delta E$, ] ++(0,-2)
to [battery2, invert, l=$E$] ++(0, -1)
node[ground](GND){};
\draw (0,0) to [R=$R_s$, -*] ++(3,0) node[above]{$\vD$} coordinate(vd);
\draw (vd) to [D*, l=D, f=$\iD$] (vd|-GND) node[ground]{};
\begin{scope}[red, overlay, visible on=<2->]
\draw[decoration={brace}, decorate] (-.5,-3.5) -- ++(0,3)
node[midway, left]{$E_{\mathrm{tot}}$};
\end{scope}
\end{circuitikz}
\end{column}%
\hfill%
\begin{column}{.58\linewidth}
% second column
\begin{tikzpicture}[]
\begin{axis}[
width=8cm, height=5cm,
xmin=0, xmax=1,
ymin=0, ymax=11,
domain=0:1,
axis x line = center,
axis y line = center,
axis line style = {thick, gray},
enlarge x limits,
enlarge y limits,
xlabel = {$\vD$},
% every axis x label/.append style = {below, gray},
ylabel = {$\iD$},
legend style = {nodes={right, font=\scriptsize},
at={(0.05,0.6)}, anchor=west},
clip mode = individual,
]
% notes that the values are fake to stay into PGF math
\addplot[thick, smooth, name path=diodef] {1e-3*exp(x/0.1)};
%
\only<2->{
\addplot[red, samples=2, name path=load1 ] {6 - 6*x};
\path (0,6) coordinate(deltaE pos) node[left, red, overlay]{$E_\mathrm{tot}$};
\path[red, overlay] (0.8, 8) node[anchor=west, inner sep=1pt, fill=white](F)
{$E_{\mathrm{tot}}=R_s\iD + \vD$};
\draw[red, overlay, ->] (F.west) -- (0.6,3);
\path [name intersections={of=diodef and load1}] (intersection-1)
node[circ]{} coordinate(P1);
\draw [red, dashed] (P1|-0,0) coordinate(deltaid pos) -- (P1) --
(P1-|0,0) coordinate(deltavd pos);
}
%
\only<3->{
\addplot[blue, samples=2, name path=load2 ] {7 - 6*x};
\path [name intersections={of=diodef and load2}] (intersection-1)
node[circ]{} coordinate(P2);
\draw [blue, dashed] (P2|-0,0) -- (P2) -- (P2-|0,0);
%
\addplot[darkgreen, samples=2, name path=load3 ] {5 - 6*x};
\path [name intersections={of=diodef and load3}] (intersection-1)
node[circ]{} coordinate(P3);
\draw [darkgreen, dashed] (P3|-0,0) -- (P3) -- (P3-|0,0);
% vstubs for sinusoidal
\draw [thin, dashed, blue] (0,7) -- (0.2,7);
\draw [thin, dashed, blue] (0,5) -- (0.2,5);
}
\end{axis}
\pgfplotsset{minivgraph/.style={
width=2.5cm, height=1cm, scale only axis,
xmin=0, xmax=1000, domain=0:1000, samples=50, smooth,
ymin=-1.1, ymax=1.1,
axis x line = center, axis y line=center,
xticklabel = \empty,
yticklabel = \empty,
every axis x label/.append style={right},
every axis y label/.append style={at={(0.5,1)},
anchor=center, inner sep=1pt},
xlabel=$t$,
}}
\only<4->{
\begin{axis}[at=(deltaE pos), anchor=west, blue,
minivgraph,
ylabel=$\Delta E\eq v_s(t)$,
]
\addplot [thick] {0.55*sin(x)};
\end{axis}
}
\only<5->{
\begin{axis}[at=(deltavd pos), anchor=west, darkgreen,
minivgraph,
ylabel=$\Delta \iD$,
]
\addplot [thick] {0.45*sin(x)};
\end{axis}
\begin{axis}[at=(deltaid pos), rotate=-90, anchor=north, red, overlay,
minivgraph,
width=2cm, xmax=800,
ylabel=$\Delta \vD$,
every axis x label/.append style={below},
every axis y label/.append style={at={(1,1)},
anchor=center, inner sep=1pt},
]
\addplot [thick] {0.55*sin(x)};
\end{axis}
}
\end{tikzpicture}
\end{column}
\end{columns}
\[
\iD = f(\vD) = I_0\biggl(e^{\openfrac{\vD}{V_T}}-1\biggr),
\quad V_T=\SI{25.9}{\mV} \text{ at \SI{300}{\kelvin}}
\]
\[
\vD\gg V_T \Rightarrow \iD \approx I_0e^{{\vD}/{V_T}}
\]
\end{frame}
\end{document}