我正在尝试使用 TikZ 生成一些图,代码如下:
这与babel
、、fontenc
或无关inputenc
;我曾尝试删除它们,但没有成功。
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage[spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\parindent=40pt
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel=$y$]
\addplot[smooth,mark=*,blue] plot coordinates {
(0,2)
(2,3)
(3,1)
};
\addlegendentry{Case 1}
\addplot[smooth,color=red,mark=x]
plot coordinates {
(0,0)
(1,1)
(2,1)
(3,2)
};
\addlegendentry{Case 2}
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}
[
axis equal image,
width = 5cm,
height = 5cm,
xmin=-1.0,xmax=10,
ymin=-1.0,ymax=6,
xlabel = {$f$},
ylabel = {$I$},
xtick = {0},
xticklabels={},
ytick = {0},
yticklabels={},
grid = none,
axis x line=middle,
axis y line=middle,
clip=false,
small,
]
\draw[-] (axis cs:0,0) to [in=180,out=0] (axis cs:4,4) to [in=180,out=0] (axis cs:8,0);
\draw[dashed] (axis cs:4,4) -- (axis cs:4,0) node [below] {$f_r$};
\draw[dashed] (axis cs:4,4) -- (axis cs:0,4) node [left] {$\frac{V_s}{R}$};
\end{axis}
\end{tikzpicture}
\end{document}
但我的结果将所有文本放在每个图的同一位置。