三维图具有较大的 z 轴,所有值都显示在刻度上

三维图具有较大的 z 轴,所有值都显示在刻度上

我正在尝试使用以下代码构建三维图形。

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{figure} [H]
\centering
\pgfplotsset{compat=newest}
\begin{tikzpicture} [scale=0.8]
\begin{axis}[
view = {5}{8},
grid=both,
legend cell align=left,
xticklabels = {10,20,30,40,50,60,70,80,90,100,110},
yticklabels ={0.03,0.05,0.07,0.09,0.11,0.13,0.23,0.33,0.43,0.53},
zticklabels = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
xtick={1,2,3,4,5,6,7,8,9,10,11},
ytick={1,2,3,4,5,6,7,8,9,10},
tick label style={font=\tiny},
legend pos=north east,
legend columns = 4,
y tick label style={rotate=90},
ylabel=distinctness,
xlabel=Dimension,
zlabel=silhouette coefficient,
y label style={rotate=57},
]
\addplot3  coordinates{(1,1,0.27)(1,2,0.27)(1,3,0.27)(1,4,0.27)(1,5,0.32)(1,6,0.38)   (1,7,0.66)(1,8,0.80)(1,9,0.80)(1,10,0.85)};
\addplot3  coordinates{(2,1,0.23)(2,2,0.30)(2,3,0.33)(2,4,0.40)(2,5,0.46)(2,6,0.43)(2,7,0.62)(2,8,0.80)(2,9,0.85)(2,10,0.87)};
\addplot3  coordinates{(3,1,0.83)(3,2,0.85)(3,3,0.86)(3,4,0.86)(3,5,0.86)(3,6,0.57)(3,7,0.74)(3,8,0.78)(3,9,0.86)(3,10,0.87)};
\addplot3  coordinates{(4,1,0.86)(4,2,0.88)(4,3,0.90)(4,4,0.56)(4,5,0.56)(4,6,0.52)(4,7,0.64)(4,8,0.78)(4,9,0.84)(4,10,0.87)};
\addplot3  coordinates{(5,1,0.92)(5,2,0.92)(5,3,0.52)(5,4,0.57)(5,5,0.59)(5,6,0.58)(5,7,0.63)(5,8,0.81)(5,9,0.82)(5,10,0.85)};
\addplot3  coordinates{(6,1,0.86)(6,2,0.90)(6,3,0.91)(6,4,0.85)(6,5,0.86)(6,6,0.87)(6,7,0.88)(6,8,0.80)(6,9,0.82)(6,10,0.86)};
\addplot3  coordinates{(7,1,0.83)(7,2,0.87)(7,3,0.88)(7,4,0.88)(7,5,0.86)(7,6,0.86)(7,7,0.83)(7,8,0.79)(7,9,0.84)(7,10,0.86)};
\addplot3  coordinates{(8,1,0.66)(8,2,0.76)(8,3,0.76)(8,4,0.76)(8,5,0.79)(8,6,0.80)(8,7,0.68)(8,8,0.81)(8,9,0.84)(8,10,0.85)};
\addplot3  coordinates{(9,1,0.79)(9,2,0.84)(9,3,0.56)(9,4,0.59)(9,5,0.63)(9,6,0.65)(9,7,0.73)(9,8,0.80)(9,9,0.84)(9,10,0.85)};
\addplot3  coordinates{(10,1,0.36)(10,2,0.52)(10,3,0.52)(10,4,0.59)(10,5,0.63)(10,6,0.64)(10,7,0.73)(10,8,0.80)(10,9,0.84)(10,10,0.86)};
\addplot3  coordinates{(11,1,0.36)(11,2,0.52)(11,3,0.52)(11,4,0.59)(11,5,0.63)(11,6,0.64)(11,7,0.73)(11,8,0.80)(11,9,0.84)(11,10,0.86)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

存在一些问题,可能还有很多,您可以建议我做哪些其他更改,以便情节更具说明性。我知道但不知道如何解决的问题:

  1. 如何增加 y 轴的长度,以便所有刻度和标签都像 x 轴的标签一样清晰可读
  2. 我如何zticklabels = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}在代码中写入显示 z 轴的所有刻度,但绘图未显示所有值。这里出了什么问题?

  3. view 属性是什么意思?我知道更改值会改变绘图沿 z 轴的方向。但我不明白它是如何工作的,也就是说,我不知道 views 的什么值会带来什么样的效果?

我将非常感激您提供的任何建议。谢谢。

答案1

  • 要点1:使用钥匙plot box ratio
  • 第 2 点:一种解决方法是明确给出刻度,就像您对 x 轴和 y 轴所做的那样。但是,它们并不全部存在,我需要在手册中挖掘更多内容。
  • 建议:使用sloped键来避免需要为 y 标签的旋转提供明确的角度(该值可能会随着其他视图而改变)。

在此处输入图片描述

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\pgfplotsset{compat=newest}
\begin{tikzpicture}
\begin{axis}[
plot box ratio = 1 3 1,
view = {5}{8},
grid = both,
xticklabels = {10,20,30,40,50,60,70,80,90,100,110},
yticklabels = {0.03,0.05,0.07,0.09,0.11,0.13,0.23,0.33,0.43,0.53},
zticklabels = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
xtick = {1,2,3,4,5,6,7,8,9,10,11},
ytick = {1,2,3,4,5,6,7,8,9,10},
ztick = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1},
tick label style = {font=\tiny},
y tick label style = {rotate=90},
xlabel = Dimension,
ylabel = distinctness,
zlabel = silhouette coefficient,
y label style = sloped,
]
\addplot3  coordinates{(1,1,0.27)(1,2,0.27)(1,3,0.27)(1,4,0.27)(1,5,0.32)(1,6,0.38)   (1,7,0.66)(1,8,0.80)(1,9,0.80)(1,10,0.85)};
\addplot3  coordinates{(2,1,0.23)(2,2,0.30)(2,3,0.33)(2,4,0.40)(2,5,0.46)(2,6,0.43)(2,7,0.62)(2,8,0.80)(2,9,0.85)(2,10,0.87)};
\addplot3  coordinates{(3,1,0.83)(3,2,0.85)(3,3,0.86)(3,4,0.86)(3,5,0.86)(3,6,0.57)(3,7,0.74)(3,8,0.78)(3,9,0.86)(3,10,0.87)};
\addplot3  coordinates{(4,1,0.86)(4,2,0.88)(4,3,0.90)(4,4,0.56)(4,5,0.56)(4,6,0.52)(4,7,0.64)(4,8,0.78)(4,9,0.84)(4,10,0.87)};
\addplot3  coordinates{(5,1,0.92)(5,2,0.92)(5,3,0.52)(5,4,0.57)(5,5,0.59)(5,6,0.58)(5,7,0.63)(5,8,0.81)(5,9,0.82)(5,10,0.85)};
\addplot3  coordinates{(6,1,0.86)(6,2,0.90)(6,3,0.91)(6,4,0.85)(6,5,0.86)(6,6,0.87)(6,7,0.88)(6,8,0.80)(6,9,0.82)(6,10,0.86)};
\addplot3  coordinates{(7,1,0.83)(7,2,0.87)(7,3,0.88)(7,4,0.88)(7,5,0.86)(7,6,0.86)(7,7,0.83)(7,8,0.79)(7,9,0.84)(7,10,0.86)};
\addplot3  coordinates{(8,1,0.66)(8,2,0.76)(8,3,0.76)(8,4,0.76)(8,5,0.79)(8,6,0.80)(8,7,0.68)(8,8,0.81)(8,9,0.84)(8,10,0.85)};
\addplot3  coordinates{(9,1,0.79)(9,2,0.84)(9,3,0.56)(9,4,0.59)(9,5,0.63)(9,6,0.65)(9,7,0.73)(9,8,0.80)(9,9,0.84)(9,10,0.85)};
\addplot3  coordinates{(10,1,0.36)(10,2,0.52)(10,3,0.52)(10,4,0.59)(10,5,0.63)(10,6,0.64)(10,7,0.73)(10,8,0.80)(10,9,0.84)(10,10,0.86)};
\addplot3  coordinates{(11,1,0.36)(11,2,0.52)(11,3,0.52)(11,4,0.59)(11,5,0.63)(11,6,0.64)(11,7,0.73)(11,8,0.80)(11,9,0.84)(11,10,0.86)};
\end{axis}
\end{tikzpicture}
\end{document}
  • 要点3:如下图所示,键的不同值view

在此处输入图片描述

相关内容