TransWikia.com

pgfplots: How to scale axis so that cubes stick together

TeX - LaTeX Asked on December 6, 2020

I have a 3D-plot which produces

enter image description here

What is the correct way to scale the x-axis and y-axis so that the cubes 0,1,2,3 stick together? Something like this:

enter image description here

documentclass[border=10pt, varwidth]{standalone}
usepackage{pgfplotstable}
usepackage{pgfplots}
pgfplotsset{compat=1.17}

begin{document}
pgfplotstableread[col sep=comma,header=true]{
X,   Y,    Z
0,    0,   0
1,    0,   0
2,    0,   0
1,    -1,   0
4,    0,   0
}{datatable}

begin{tikzpicture}
begin{axis}[
%xmin=0, xmax=6, 
ymin=-1, ymax=1,
zmin=0, zmax=1, 
grid=both,
point meta=explicit, % colors 1/2
xlabel={$x$},  ylabel={$y$},   zlabel={$z$},
% x=3mm, y=1cm, z=1cm, % not a good idea
]
addplot3[scatter, mark=*, only marks,
mark=cube*, mark size=7,  
nodes near coords*=coordindex,
] table [x=X, y=Y,z=Z,
meta expr={thisrow{X}} % colors 2/2
] {datatable};
end{axis}
end{tikzpicture}
end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP