Creating a 3D surface plot from a data of 3 variables and 1 response
1 view (last 30 days)
Show older comments
Based on the below data, how can I create a surface plot with a colorbar for the response given data below: Hoping for your kind help!
A=[195 65 195 65 195 65 195 65]; %parameter 1
B=[120 120 150 150 120 120 150 150]; %parameter 2
C=[2 2 2 2 1 1 1 1]; %parameter 3
Y=[527 570 537 549 728 780 725 748]; %response
I have made a code below that represents a scatter plot, however, I wanted to know how I can do a surface plot with the response represented in the colorbar. Hoping for someone's help.
clc;
close all;
A=[195 65 195 65 195 65 195 65]; %parameter 1
B=[120 120 150 150 120 120 150 150]; %parameter 2
C=[2 2 2 2 1 1 1 1]; %parameter 3
Y=[527 570 537 549 728 780 725 748]; %response
scatter3(A,B,C,8,Y,'filled') % draw the scatter plot
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
xlabel('Parameter 1')
ylabel('Parameter 2')
zlabel('Parameter 3')
cb = colorbar; % create and label the colorbar
cb.Label.String = 'Response';
0 Comments
Answers (1)
Benjamin Campbell
on 4 Nov 2022
You are trying to represent 4 dimensions which you can do in 3 spatial dimensions, and the fourth dimension colour. If you wanted it to be more like a surface plot it would have to be a cube of continuous colour changes which is impossible to see.
I would recommend breaking the data up into two surface plots and using:
https://ch.mathworks.com/help/matlab/ref/surf.html
2 Comments
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!