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

10 views (last 30 days)
Amjad Green
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 can be any order
also is there a way to draw in more than 3D if im working with x1,x2,x3,x4...?

Accepted Answer

Walter Roberson
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
  • 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 .
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.
Walter Roberson
Walter Roberson on 20 Mar 2018

Sign in to comment.

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by