我正在尝试使用 tikzpicture 绘制以下图表。该图表有点复杂,有两个 y 轴和一个 x 轴。我不知道如何添加坐标来绘制这两个图表。
\begin{tikzpicture}
\begin{axis}[
xlabel={Voltage (V)},
ylabel={Current (A)},
xmin=0, xmax=1.5,
ymin=0, ymax=1.2,
grid=both,
grid style={line width=.1pt, draw=gray!10},
legend pos=south east,
]
\addplot[color=red,mark=none]
coordinates {(0,0) (0.5,0.8) (1,0.9) (1.5,0.8)};
\end{axis}
\begin{axis}[
xlabel={Voltage (V)},
ylabel={Power (W)},
%xmin=0, xmax=1.5,
ymin=0, ymax=0.5,
grid=both,
grid style={line width=.1pt, draw=gray!10},
axis y line*=right,
axis x line=none,
legend pos=south east,
]
\addplot[color=blue,mark=none,samples=100]
coordinates {(0,1) (0.2,1) (0.4,1) (0.6,1) (0.8,1) (1,1)(1.2,0.8)(1.4,0)};
\end{axis}
\filldraw[blue] (1,0.9) circle (2pt);
\node[right, blue] at (1,0.9) {MPP};
\end{tikzpicture}
图片取自: 取自:https://electricajournal.org/Content/files/sayilar/17/1-11.pdf
答案1
您可以使用smooth
选项addplot
来让您的图表更加美观。如果您想删除刻度和标签,请使用\pgfplotsset{ticks=none}
。如果只删除刻度标签,请将xticklabels={,,}
和添加yticklabels={,,}
到环境选项中axis
。
\documentclass[tikz,border=5]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,height=6cm,compat=1.18}
\usetikzlibrary{positioning,arrows}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{set layers}
%\pgfplotsset{ticks=none}
\begin{axis}[
scale only axis,
axis on top=true,
xmin=0, xmax=1.6,
ymin=0, ymax=1.3,
axis y line=right,
axis y line shift=-0.2,
axis x line=none,
ylabel=Power (W),
%yticklabels={,,},
clip mode=individual,
]
\coordinate (MPP) at (axis cs:1.1,0.8);
\draw[dashed] (MPP) -- +(-1.1,0) node[left] {$I_{\mathrm{mp}}$};
\fill[shading=axis,left color=green!10!white, right color=green!30!white,shading angle=135] (axis cs:0,0) rectangle (MPP);
\node[above] at (axis cs:1.4,1.3) {Power};
\node[above] at (axis cs:1.6,0) {Volts};
\addplot[color=blue,mark=none,very thick,smooth]
coordinates {(0,1) (0.2,1) (0.4,1) (0.6,1) (0.8,1) (0.9,0.97) (1,0.9) (1.1,0.8) (1.2,0.6) (1.4,0)};
\draw[blue] (MPP) circle (5pt);
\node [above left = 5em and 2em of MPP] {MPP} edge[shorten >=6pt,-stealth] (MPP);
\node[anchor=south] at (axis cs:0.5,1) {$I$-$V$ Curve};
\node[left,yshift=2pt] at (axis cs:0,1) {$I_{\mathrm{max}}$};
\end{axis}
\begin{axis}[
scale only axis,
axis on top=true,
xmin=0, xmax=1.6,
ymin=0, ymax=1.1,
axis y line=left,
axis x line=bottom,
xlabel=Voltage (V),
ylabel=Current (A),
%yticklabels={,,},
%xticklabels={,,},
clip mode=individual,
]
\coordinate (Pmax) at (axis cs:1.1,0.97);
\draw[dashed] (Pmax) -- +(0.3,0) node[right,yshift=-2pt] {$P_{\mathrm{max}}$};
\draw[dashed] (Pmax) -- +(0,-0.97) node[below] {$V_{\mathrm{mp}}$};
\node[above] at (axis cs:0,1.1) {Amps};
\addplot[color=red,mark=none,very thick,smooth]
coordinates {(0,0) (0.1,0.1) (0.2,0.2) (0.3,0.3) (0.4,0.4) (0.5,0.5) (0.6,0.6) (0.7,0.7) (0.8,0.8) (0.9,0.88) (1,0.95) (1.1,0.97) (1.2,0.9) (1.3,0.6) (1.4,0)};
\node[anchor=south east] at (axis cs:0.5,0.5) {$P$-$V$ Curve};
\node at (axis cs:0.8,0.3) {$\mathrm{Area}=V_{\mathrm{mp}}\times I_{\mathrm{mp}}$};
\end{axis}
\end{tikzpicture}
\end{document}