I am trying to build a 3 dimension graph using the following code.
\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}
There are some issues with it, may be many, you can suggest what other changes can I make so that the plot is more illustrative.
Issues that I know of but don't know how to solve:
- How can I increase the length of y-axis so that all the ticks and labels are clearly readable like the labels of x-axis
-
How can I show all the ticks for z-axis, I wrote
zticklabels = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}
in my code, but the plot does not show all the values. What is going wrong here? -
What is the meaning of view attribute? I know changing the values changes the orientation of plot along the z-axis. But what I don't understand is how it works, means, I don't know what value of views will bring what kind of effect?
I will appreciate any suggestion that you can provide. Thanks.
Best Answer
plot box ratio
.sloped
key to avoid the need to give an explicit angle to the rotation of the y label (that value might change with other views).view
.