See my comment on why you likely don't want to do this, but the general way of plotting in 3D is

x = 1:10;
y = 1:5;
[X Y] = meshgrid(x, y);
Z = X.^2 + 2 .* Y;      % in general, Z = f(X, Y)
plot3(X, Y, Z, '+')
Answer from Richie Cotton on Stack Overflow
🌐
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › discrete data plots
scatter3 - 3-D scatter plot - MATLAB
Create plots by passing a table to the scatter3 function followed by the variables you want to plot. When you specify your data as a table, the axis labels and the legend (if present) are automatically labeled using the table variable names. ... Run the command by entering it in the MATLAB ...
🌐
MathWorks
mathworks.com › matlab mobile › matlab mobile fundamentals
Creating 3-D Scatter Plots - MATLAB & Simulink
Load data on ozone levels. load ... 16; offset = 1; c = response - min(response); c = round((nc-1-2*offset)*c/max(c)+1+offset); Create a 3-D scatter plot using the scatter3 function....
🌐
MathWorks
mathworks.com › text analytics toolbox › display and presentation
textscatter3 - 3-D scatter plot of text - MATLAB
This MATLAB function creates a 3-D text scatter plot with elements of str at the locations specified by the vectors x, y, and z.
🌐
Plotly
plotly.com › matlab › 3d-scatter-plots
3d scatter plots in MATLAB
Over 10 examples of 3D Scatter Plots including changing color, size, log axes, and more in MATLAB.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 390858-how-to-make-a-3d-scatterplot-with-perspective
How to make a 3D scatterplot with perspective - MATLAB Answers - MATLAB Central
March 26, 2018 - I have arrays of X, Y and Z points and have been playing with scatter3(), but need perspective in the Y direction to better show position, and other things like turning off the Z axes, etc. Is this possible? Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/390858-how-to-make-a-3d-scatterplot-with-perspective#answer_312100
🌐
MathWorks
mathworks.com › matlabcentral › answers › 303539-how-do-i-make-a-3d-scatter-plot
How do I make a 3d scatter plot? - MATLAB Answers - MATLAB Central
September 18, 2016 - I am trying to create a very easy scatter plot. Is there also a a way to look at the cross-section of the 3d scatter plot? Sign in to comment. Sign in to answer this question. ... https://www.mathworks.com/matlabcentral/answers/303539-how-do-i-make-a-3d-scatter-plot#answer_235168
Find elsewhere
🌐
Matplotlib
matplotlib.org › stable › gallery › mplot3d › scatter3d.html
3D scatterplot — Matplotlib 3.10.8 documentation
""" return (vmax - vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(projection='3d') n = 100 # For each set of style and range settings, plot n random points in the box # defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh]. for m, zlow, zhigh in [('o', -50, -25), ('^', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zlow, zhigh) ax.scatter(xs, ys, zs, marker=m) ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show()
Top answer
1 of 1
4
3D density plot demos Here's an assortment of 3D density visualizations though there are many other ways to visualize 3D density. The script was written on the fly and each demo can be cleaned up and optimized. Consider it a sketch, a scratch pad, a Jackson Pollock painting, or a wall in an italian restaurant after a long day of "see what sticks" tests. All plots show the same data displayed using different visualizations. Some plots require recent release of matlab (e.g. bubblechart3 - r2020b). Control the number of bins with the nBins variable. See inline comment for details. %% Create 3D scatter data n = 2000; xyz = zeros(n,3); xyz(:,1) = randn(n,1).*2+8; xyz(:,2) = randn(n,1).*5-2; xyz(:,3) = randn(n,1).*3+4; ri = randperm(n,round(n*.1)); xyz(ri,:) = xyz(ri,:).*[.8,.4,.5]+[-8,12,6]; %% Compute density % Put points into 3D bins; xyzBinNum is an nx3 matrix containing % the bin ID for n values in xyz for the [x,y,z] axes. nBins = 8; % number of bins xbins = linspace(min(xyz(:,1)),max(xyz(:,1))*1,nBins+1); ybins = linspace(min(xyz(:,2)),max(xyz(:,2))*1,nBins+1); zbins = linspace(min(xyz(:,3)),max(xyz(:,3))*1,nBins+1); xyzBinNum = [... discretize(xyz(:,1),xbins), ... discretize(xyz(:,2),ybins), ... discretize(xyz(:,3),zbins), ... ]; % bin3D is a mx3 matrix of m unique 3D bins that appear % in xyzBinNum, sorted. binNum is a nx1 vector of bin % numbers identifying the bin for each xyz point. For example, % b=xyz(j,:) belongs to bins3D(b,:). [bins3D, ~, binNum] = unique(xyzBinNum, 'rows'); % density is a mx1 vector of integers showing the number of % xyz points in each of the bins3D. To see the number of points % in bins3D(k,:), density(k). density = histcounts(binNum,[1:size(bins3D,1),inf])'; % Compute bin centers xbinCnt = xbins(2:end)-diff(xbins)/2; ybinCnt = ybins(2:end)-diff(ybins)/2; zbinCnt = zbins(2:end)-diff(zbins)/2; %% Plot raw data fig = figure(); tiledlayout('flow') nexttile() plot3(... xyz(:,1), ... xyz(:,2), ... xyz(:,3), '.') title('Raw data') grid on box on %% Plot bubblechart3 nexttile() bubblechart3(... xbinCnt(bins3D(:,1)), ... ybinCnt(bins3D(:,2)), ... zbinCnt(bins3D(:,3)), ... density, ... density, ... 'MarkerFaceAlpha', .3, ... 'MarkerEdgeAlpha', .3) title('bubblechart3') %% Plot scatter3 nexttile() scatter3(... xbinCnt(bins3D(:,1)), ... ybinCnt(bins3D(:,2)), ... zbinCnt(bins3D(:,3)), ... density*5+5, ... density, 'filled', ... 'MarkerFaceAlpha',.6) title('scatter3') box on %% Plot marginal histograms % Histograms are normalized and are not related to % the axis ticks though their relative height within % the axes shows the population density (ie, 30% of % the axis hight means that the bin contains 30% of % the data. nexttile() plot3(... xyz(:,1), ... xyz(:,2), ... xyz(:,3), '.') grid on box on hold on xcount = histcounts(xyz(:,1),xbins)/size(xyz,1)*range(zlim())+min(zlim()); ycount = histcounts(xyz(:,2),ybins)/size(xyz,1)*range(zlim())+min(zlim()); % x density plotted on xz plane patch(repelem(xbins(:),2,1), ... repmat(max(ybins),numel(xbins)*2,1), ... [min(zbins);repelem(xcount(:),2,1);min(zbins)], ... 'r','FaceAlpha',.25) % y density plotted on yz plane patch(repmat(max(xbins),numel(xbins)*2,1), ... repelem(ybins(:),2,1), ... [min(zbins);repelem(ycount(:),2,1);min(zbins)], ... 'r','FaceAlpha',.25) title('Marginal histograms') %% Plot marginal surface plots % All 3 surface planes use the same color limit. nexttile() scatter3(... xyz(:,1), ... xyz(:,2), ... xyz(:,3), ... 10, 'w', 'filled', ... 'MarkerFaceAlpha', .5) hold on grid off xlim([min(xbins), max(xbins)]) ylim([min(ybins), max(ybins)]) zlim([min(zbins), max(zbins)]) % xz plane density [xm,zm] = ndgrid(xbins, zbins); xzCount = histcounts2(xyz(:,1),xyz(:,3), xbins,zbins); surf(xm,max(ylim())*ones(size(xm)),zm,xzCount,'FaceAlpha',.8) % yz plane density [ym,zm] = ndgrid(ybins, zbins); yzCount = histcounts2(xyz(:,2),xyz(:,3), ybins,zbins); surf(max(xlim())*ones(size(xm)),ym,zm,yzCount,'FaceAlpha',.8) % xy plane density [xm,ym] = ndgrid(xbins, ybins); xyCount = histcounts2(xyz(:,1),xyz(:,2), xbins,ybins); surf(xm,ym,min(zlim())*ones(size(xm)),xyCount,'FaceAlpha',.8) set(gca,'LineWidth',3) box on maxCount = max([xyCount(:);xyCount(:);xzCount(:)]); set(gca,'colormap',hot(256),'CLim',[0,maxCount]) cb = colorbar(); ylabel(cb,'Number of dots') title('Density Planes') %% Equate all axis limits fig.UserData.hlink = linkprop(findobj(fig,'type','axes'),{'xlim','ylim','zlim'});
🌐
MathWorks
mathworks.com › matlabcentral › answers › 479637-plotting-3d-scatter-plot-from-elements-in-a-matrix
Plotting 3D scatter plot from elements in a matrix - MATLAB Answers - MATLAB Central
September 9, 2019 - Hello all, I have a matrix A with dimensions 47 x 4. I would like to plot the values in the matrix in a 3D plot. For e.g element A(4, 5) = 12 should be represented with x=4, y=5 and z= 12. Sinc...
🌐
MathWorks
mathworks.com › matlab › graphics › 2-d and 3-d plots › discrete data plots
scatter - Scatter plot - MATLAB
Create plots by passing a table to the scatter function followed by the variables you want to plot. When you specify your data as a table, the axis labels and the legend (if present) are automatically labeled using the table variable names. ... Run the command by entering it in the MATLAB Command ...
🌐
MathWorks
mathworks.com › matlabcentral › fileexchange › 35288-matlab-plot-gallery-scatter-plot-3d
MATLAB Plot Gallery - Scatter Plot 3D - File Exchange - MATLAB Central
December 19, 2018 - This is an example of how to create a 3D scatter plot in MATLAB®. Read about the "scatter3" function in the MATLAB documentation.
🌐
Mathworks
se.mathworks.com › matlabcentral › answers › 416596-3d-scatter-plots
3D scatter plots - MATLAB Answers - MATLAB Central
August 28, 2018 - (1,2,3) ,(4,5,6) I would like to plot these in a 3D graph. ... Sign in to comment. Sign in to answer this question. ... I don't see a question, so have fun! You'll probably be using either scatter3() or plot3() - they'll both do it.
🌐
EDUCBA
educba.com › home › data science › data science tutorials › matlab tutorial › matlab 3d scatter plot
Matlab 3d scatter plot | Learn the Examples of Matlab 3d scatter plot
March 13, 2023 - 3 D scatter plots are used to interpret the spread of data and identify any outliers. Scatter plots are very useful in data science, where relationships in the test data are used to create algorithms to predict the output.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai