second_y_axis

../_images/sphx_glr_second_y_axis.svg
\documentclass[]{standalone}

\usepackage[]{graphicx}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\tikzset{>=latex}
\usetikzlibrary{arrows,arrows.meta}
\usepackage{steinmetz}
\newcommand*{\equal}{=}

\usepackage{tikz-3dplot}
\usetikzlibrary{decorations.markings}

\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{>}}},postaction={decorate}}}

\begin{document}
  \pgfplotstableread{
    I     V       P
    0.1   0.21    0.021
    0.5   1.07    0.54
    1.0   2.30    2.3
    1.6   3.20    5.14
    2.0   3.73    7.46
    3.0   6.22   18.66
    5.0  10.02   50.10
    8.0  16.04  128.32
    10.0  20.0  200.00
  }\datatable
  
\begin{tikzpicture}
    \begin{axis}[
    width=0.9\textwidth,
    xmin=0,xmax=10.5,
    ymin=0,ymax=22,
    grid=both,
    axis x line=bottom,
    axis y line=left,
    %xtick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0},
    xlabel={$I$[mA]},
    ylabel={$V$[V]},
    legend style={at={(0.03,0.9)},anchor=west}
    ],
    \draw (axis cs:0,0) node[below left] {$0$};
    \addplot[thick, domain=0.08:10.2] {2*x};
    \addplot[mark=*, only marks,legend] table[x={I},y={V}] {\datatable}; \label{VvsI}
    \draw[very thick,->] (axis cs: 2.5,5) --(axis cs:1.5,5);
    \addlegendentry{};
    \addlegendentry{V};
    \end{axis}
    \begin{axis}[
    width=0.9\textwidth,
    xmin=0,xmax=10.5,
    ymin=0,ymax=220,
    grid=both,
    axis x line=bottom,
    axis y line=right,
    %xtick={0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0},
    xlabel={$I$[mA]},
    ylabel={$P$[mW]},
    ]
    \addplot[dashed,samples=100,domain=0.08:10.2] {2*x^2};
    \addplot[mark=triangle,only marks,legend] table[x={I},y={P}] {\datatable}; \label{PvsI}
    \draw[very thick,->] (axis cs: 5,40) --(axis cs:6,40);
    \end{axis}
\end{tikzpicture}

\end{document}