Using scatter3 in conjunction with setting axis limits draws at wrong coordinates
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
JP Schnyder
il 3 Dic 2019
Risposto: Navya Seelam
il 6 Dic 2019
I try to plot a point at a specific 3d coordinate. But if I use set(gca, 'XLim' or 'YLim' or 'ZLim',...), the point is plotted at a wrong position in the 3D graph. Below, I put the code without set(gca ...) together with the plotted result. Then, I add code using set(gca ...) with the result.
close all
figure
p0 = [0 0 0];
p1 = [0 0 0];
plot3(p0,p1,p1)
grid
xlabel('x')
ylabel('y')
zlabel('z')
hold on
x = 1
y = 3
z = 9
scatter3(x,y,z)
%plot3(x,y,z,'*')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/252453/Screenshot_20191203_172904.jpg)
close all
figure
p0 = [0 0 0];
p1 = [0 0 0];
plot3(p0,p1,p1)
grid
xlabel('x')
ylabel('y')
zlabel('z')
lim = [0 10];
tick = (0:1:10);
set(gca,'XLim',lim)
set(gca,'XTick',tick)
set(gca,'YLim',lim)
set(gca,'YTick',tick)
set(gca,'ZLim',lim)
set(gca,'ZTick',tick)
hold on
x = 1
y = 3
z = 9
scatter3(x,y,z)
%plot3(x,y,z,'*')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/252456/Screenshot_20191203_172940.jpg)
Using plot3 instead of scatter gives the same results.
0 Commenti
Risposta accettata
Navya Seelam
il 6 Dic 2019
Hi,
The point is being plotted at right position. Try rotating the plot to make sure the point is at right position
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!