# how to plot y=f(x1,x2) in 3D

10 views (last 30 days)
Amjad Green on 20 Mar 2018
Commented: Walter Roberson on 20 Mar 2018
plot3 is just linking the points, i want the answer more like a surface,the function is not linear.it can be any order
also is there a way to draw in more than 3D if im working with x1,x2,x3,x4...?

Walter Roberson on 20 Mar 2018
If f is a function handle, consider using fsurf()
"is there a way to draw in more than 3D"
For more than 3D you need to encode a dimension as one of the attributes of what you draw. The available attributes are:
• x
• y
• z
• color (for surfaces and images)
• transparency
and
• marker size
• marker shape
• marker face color
• marker edge color
Using color to represent dimension is very common, but really it has hidden difficulties; I recommend reading https://blogs.mathworks.com/steve/2014/10/20/a-new-colormap-for-matlab-part-2-troubles-with-rainbows/ .
Using transparency together with color is risky. Transparency against a white background affects brightness (well, saturation perhaps technically), but if you are already encoding dimension through brightness then it can be difficult for someone to tell the difference between a transparency difference and a brightness difference.
My personal practice is:
• for three spatial dimensions and one data dimension, represent the data by color, with transparency set constant so that you can see objects "behind" the front ones
• otherwise, encode as x, y, z, marker face color, marker size
If you have more than 5 continuous dimensions then you probably cannot reasonably represent the data in a single graph.
I find altering marker edge color to be effectively unreadable.
If one of your dimensions is discrete with no more than about 6 cases, or can reasonably be made discrete, then it can be encoded through marker shape. marker shape is not typically perceived as continuous: you can encode difference through marker shape, but people are probably not going to understand value encoded through marker shape. You could code using the markers . v s p h (circle, triangle, square, pentagon, hexagon), but in my experience people will not be able to count sides and mentally resolve that as a spatial dimension.
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 20 Mar 2018
https://www.mathworks.com/help/stats/gplotmatrix.html