轴标签的默认方向是水平的,但我想将其更改为与 3D 图中轴平行。例如:
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=2 by 1,
horizontal sep=2cm,
},
enlarge x limits=true,
every axis label/.append style={font=\scriptsize},
width=7cm,
]
\nextgroupplot[title={\scriptsize first figure},xlabel={x1 label},ylabel={y1 label},zlabel={z1 label},xmin=0.65,xmax=0.74]%
\addplot3[only marks,mark size=0.7pt] table {
x y z
0.65 0.31 0.01
0.66 0.32 0.00
0.67 0.33 0.03
0.68 0.34 0.01
0.69 0.35 0.02
};
\nextgroupplot[title={\scriptsize second figure},xlabel={x2 label},ylabel={y2 label},zlabel={z2 label},xmin=0.65,xmax=0.74]%
\addplot3[only marks,mark size=0.7pt] table {
x y z
0.65 0.55 0.11
0.65 0.56 0.20
0.66 0.60 0.33
0.66 0.58 0.11
0.66 0.59 0.22
};
\end{groupplot}
\end{tikzpicture}
\label{fig:enter-label}
\end{figure}
\end{document}
如何让 x 轴标签位于与 x 轴平行的红线位置?如何让 y 轴标签位于与 y 轴平行的黄线位置?
答案1
你要
every axis x label/.append style=sloped,
every axis y label/.append style={sloped, at={(rel axis cs: 0, 0.5, 0)}, above},
因为sloped
标签里面代表sloped like ? axis
。这将适当旋转轴标签。此外是标签通过 移至另一侧rel axis cs: 0, 0.5, 0
。键above
设置anchor=south
。
anchor=center
增加样式every axis x label
以使其更近一点可能会更有意义。
代码
\documentclass[tikz]{standalone}
%\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
%\begin{figure}
%\centering
\begin{tikzpicture}
\begin{groupplot}[
group style={
group size=2 by 1,
horizontal sep=2cm,
},
enlarge x limits=true,
every axis plot/.append style={only marks, mark size=0.7pt},
every axis title/.append style={font=\scriptsize},
every axis label/.append style={font=\scriptsize},
every axis x label/.append style=sloped,
every axis y label/.append style={sloped, at={(rel axis cs: 0, 0.5, 0)}, above},
width=7cm, xmin=0.65, xmax=0.74,
]
\nextgroupplot[title=first figure, xlabel={x1 label}, ylabel={y1 label}, zlabel={z1 label}]%
\addplot3 table {
x y z
0.65 0.31 0.01
0.66 0.32 0.00
0.67 0.33 0.03
0.68 0.34 0.01
0.69 0.35 0.02
};
\nextgroupplot[title=second figure, xlabel={x2 label}, ylabel={y2 label}, zlabel={z2 label}]%
\addplot3 table {
x y z
0.65 0.55 0.11
0.65 0.56 0.20
0.66 0.60 0.33
0.66 0.58 0.11
0.66 0.59 0.22
};
\end{groupplot}
\end{tikzpicture}
%\label{fig:enter-label}
%\end{figure}
\end{document}