matlab 三维图
axis off;% 去掉坐标轴
axistight;% 紧坐标轴
axisequal;% 等比坐标轴
axis([-0.1, 8.1, -1.1, 1.1]);% 坐标轴的显示范围
% gca: gca, h=figure(...);
set(gca,'XLim',[3 40]);% X轴的数据显示范围
set(gca,'XTick',[-3.14,0,3.14] );% X轴的记号点
set(gca,'XTicklabel',{'-pi','0','pi'});% X轴的记号
set(gca,'XTick', []);% 清除X轴的记号点
set(gca,'XGrid','on');% X轴的网格
set(gca,'XDir','reverse');% 逆转X轴
set(gca,'Xcolor','red');% X轴的颜色
1. axis([xmin xmax ymin ymax])
设置当前图形的坐标范围,分别为x轴的最小、最大值,y轴的最小最大值
2. V=axis
返回包含当前坐标范围的一个行向量
3. axis auto
将坐标轴刻度恢复为自动的默认设置
4. axis manual
冻结坐标轴刻度,此时如果hold被设定为on,那么后边的图形将使用与前面相同的坐标轴刻度范围
5. axis tight
将坐标范围设定为被绘制的数据范围
6. axis fill
这是坐标范围和屏幕的高宽比,使得坐标轴可以包含整个绘制的区域。该选项只有在PlotBoxaApectRatio或DataAspectRatioMode被设置为‘manual’模式才有效
7. axis ij
将坐标轴设置为矩阵模式。此时水平坐标轴从左到有取值,垂直坐标从上到下
8. axis xy
将坐标设置为笛卡尔模式。此时水平坐标从左到右取值,垂直坐标从下到上取值
9. axis equal
设置屏幕高宽比,使得每个坐标轴的具有均匀的刻度间隔
10. axis square
将坐标轴设置为正方形
11. axis normal
将当前的坐标轴框恢复为全尺寸,并将单位刻度的所有限制取消
12. axis vis3d
冻结屏幕高宽比,使得一个三维对象的旋转不会改变坐标轴的刻度显示
13. axis off
关闭所有的坐标轴标签、刻度、背景
14. axis on
打开所有的坐标轴标签、刻度、背景
--------------------- 本文来自 还在学习的编程小白 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/qq_35052417/article/details/76461643?utm_source=copy
1.画函数的三维图,如:Z(X,Y)=2*X.*exp(-X.^2-Y.^2)+1;
-
close all;
-
[X,Y]=meshgrid(-2:0.5:2,-2:0.5:2);%生成坐标轴
-
Z=2*X.*exp(-X.^2-Y.^2)+1;%Z是X,Y的函数
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=0;
-
num=num+1;
-
subplot(2,3,num);
-
plot3(X,Y,Z);
-
axis([-3 3 -3 3 0 2]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
mesh(X,Y,Z);
-
axis([-3 3 -3 3 0 2]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(2)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
meshc(X,Y,Z);
-
axis([-3 3 -3 3 0 2]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(3)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
surf(X,Y,Z);
-
axis([-3 3 -3 3 0 2]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(4)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
meshz(X,Y,Z);
-
axis([-3 3 -3 3 0 2]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(5)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
surf(X,Y,Z);
-
hold on;
-
stem3(X,Y,Z,'r');%画竖线
-
axis([-3 3 -3 3 0 2]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(6)');%标题
2.画矩阵的三维图
-
clc;
-
clear all;
-
close all;
-
X=[0 1 2 3 4 5 6 7 8 9];
-
Y=[0 1 2 3 4 5 6 7 8 9];
-
for i=1:1:length(X)
-
for j=1:1:length(Y)
-
Z(i,j)=mod(i*j*rand(1),9);
-
end
-
end
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=0;
-
num=num+1;
-
subplot(2,3,num);
-
plot3(X,Y,Z);
-
axis([0 9 0 9 0 9]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(1)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
mesh(X,Y,Z);
-
axis([0 9 0 9 0 9]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(2)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
meshc(X,Y,Z);
-
axis([0 9 0 9 0 9]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(3)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
surf(X,Y,Z);
-
axis([0 9 0 9 0 9]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(4)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
meshz(X,Y,Z);
-
axis([0 9 0 9 0 9]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(5)');%标题
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
num=num+1;
-
subplot(2,3,num);
-
surf(X,Y,Z);
-
hold on;
-
stem3(X,Y,Z,'r');%画竖线
-
axis([0 9 0 9 0 9]);%限定显示的范围
-
xlabel('x轴');%x轴坐标
-
ylabel('y轴');%y轴坐标
-
zlabel('z轴');%z轴坐标
-
title('http://blog.csdn.net/nuptboyzhb/ figure(6)');%标题
3.画矩阵的颜色深度图
我自己编写的一个函数:graycolor.m
%filename:graycolor.m
%郑海波 2013-01-31
%http://blog.csdn.net/nuptboyzhb/
%原理:灰度图像的伪彩色处理
%值越大,显示的颜色越蓝,越小,显示的颜色越红!
%参数:newbuf必须使二维数组或矩阵
function graycolor(newbuf);
min_n=min(min(newbuf));
max_n=max(max(newbuf));
newbuf=newbuf./(max_n-min_n)*255;
[M N]=size(newbuf);
for i=1:1:M
for j=1:1:N
R(i,j)=GrayColorR(newbuf(i,j));
G(i,j)=GrayColorG(newbuf(i,j));
B(i,j)=GrayColorB(newbuf(i,j));
end
end
img(1:1:M,1:1:N,1)=R(1:M,1:N);
img(1:1:M,1:1:N,2)=G(1:M,1:N);
img(1:1:M,1:1:N,3)=B(1:M,1:N);
imshow(uint8(img));
function r=GrayColorR(gray)
r=0;
if gray>=170
r=255;
end
if gray>=128&&gray<=170
r=255/42*(gray-128);
end
return;
function g=GrayColorG(gray)
g=0;
if gray>=84&&gray<=170
g=255;
end
if gray<=84
g=255/84*gray;
end
if gray>=170&&gray<=255
g=255/85*(255-gray);
end
return;
function b=GrayColorB(gray)
b=0;
if gray<=84
b=255;
end
if gray>=84&&gray<=128
b=255/44*(128-gray);
end
return;
函数的调用:
-
[X,Y]=meshgrid(-2:0.01:2,-2:0.01:2);%生成坐标轴
-
Z=2*X.*exp(-X.^2-Y.^2)+1;%Z是X,Y的函数
-
graycolor(Z);
-
title('http://blog.csdn.net/nuptboyzhb/');%标题
--------------------- 本文来自 amulet0703 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/susu_love/article/details/53322180?utm_source=copy
相关阅读
线条、颜色等参数:1.简单的2维直线图 : plot(x,y)同一坐标显示n条线:plot(x,y1,x,y2,…)x = 0:pi/10:2*pi; y = sin(x); figure; hol
回归分析方法想要资源的请关注公众号: 在一起的足球自动获取资源和数十种经典算法,帮助各位提升自己之前留的是自己的qq号 感觉好多
机器感知 一个专注于SLAM、三维重建、机器视觉等相关技术文章分享的公众号 (一)原理部分 模糊C均值(Fuzzy C-means)算法简称FCM算
1.MATLAB的基本知识 1-1、基本运算与函数 在MATLAB下进行基本数学运算,只需将运算式直接打入提示号(>>)之後,并按入Enter键即可
在Matlab中,三维图形的绘制包括三维曲线,三维网线图和三维曲面图。闲话不多说,直接进入正题。首先介绍几个函数:1.plot3(x,y,z,…)其