plot3d#

plot3d(x, y, z, plottype, cmapcolors)

Description#

Plot x , y, and z data in 2-d/3-d contour/surface plot

Inputs#

x
x data
Set x=[] if it is not available
It may be 1d or 2d array
y
y data
Set y=[] if it is not available
It may be 1d or 2d array
z
z data
It may be 1d or 2d array
plottype=’imagesc’;
Plot type
‘imagesc’: 2 dimensional plot using imagesc or imshow
‘pcolor’: 2 dimensional plot using pcolor
‘contour’: 2 dimensional contour plot, number of contour=32
‘contourf’: 2 dimensional filled contour plot, number of contour=32
‘surface’: 3 dimensional surface plot
cmapcolors=’blue’;
Colormap style
‘blue’: blue colormap
‘red’: red colormap
‘green’: green colormap
‘yellow’: yellow colormap
‘purple’: purple colormap
‘brown’: brown colormap
‘gray’: gray colormap
‘blue_red’: blue-red colormap
‘red_blue’: red-blue colormap
‘blue_green’: blue-green colormap
‘green_blue’: green-blue colormap
‘green_yellow’: green-yellow colormap
‘yellow_green’: yellow-green colormap
‘red_yellow’: red-yellow colormap
‘yellow_red’: yellow-red colormap
‘cyclic’: cyclic/oscillation colormap
‘seq’: sequential colormap
User-defined colors may be used to generate colormap
User-defined colors should be defined as (M,3) array in RGB color format
At least two colors should be defined, i.e. M should be equal or larger than 2
User-defined colors values should be between 0 and 255
Any available colormap name such as ‘cool’, ‘winter’, etc also can be used

Outputs#

Examples#

[x,y]=meshgrid(linspace(-10,10,50),linspace(-10,10,50));
r=sqrt(x.^2+y.^2)+1e-10; %Add 1e-10 to prevent divide by 0
z=sin(r)./r;
plot3d(x,y,z,'surface','purple')

[x,y]=meshgrid(linspace(-10,10,21),linspace(-10,10,21));
z=(sin(x)+sin(y))./(x+y+1e-10); %Add 1e-10 to prevent divide by 0
plot3d(x,y,z,'pcolor','purple')

x(:,1)=10.*rand(1000,1);
y(:,1)=10.*rand(1000,1);
z=x.^2+y.^2;
plot3d(x,y,z,'pcolor','blue')

References#

Colormap

Color