我需要在以下笛卡尔图中添加“标题 A”和“标题 B”:
我使用了以下代码:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}[scale=1]
\draw[dotted] (-3.1,-2.1) grid (3.1,2.1);
\draw[<->] (-3.1,0)node[left] {labe1} -- (3.1,0) node[right] {label2};
\draw[<->] (0,-2.1)node[below] {label3} -- (0,2.1) node[above] {label4};
\end{tikzpicture}
\end{document}
答案1
如下
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{statistics}
\begin{document}
\begin{tikzpicture}[scale=1]
\draw[dotted] (-3.1,-2.1) grid (3.1,2.1);
\draw[<->] (-3.1,0)node[left] {labe1} -- (3.1,0) node[right] {label2};
\draw[<->] (0,-2.1)node[below] {label3} -- (0,2.1) node[above] {label4};
%% as follows
\node[rotate=90,font=\bfseries] at (-4.5,0){TitleB};
\node[font=\bfseries] at (0,3.5){TitleA};
\end{tikzpicture}
\end{document}