标签:osi image 进入 get class 图例 方式 拖动 添加
主要使用函数fill3()
使用fill3函数绘制一个立方体,并指定每个面的颜色,代码如下:
figure(1);clf;hold on
% 绘制上面
x1 = [0,1,1,0];y1 = [0,0,1,1];z1 = [1,1,1,1];
up_color = [0.7490,0.9490,0.9686];
h1 = fill3(x1,y1,z1,up_color,'FaceAlpha',0.5);
% 绘制侧面
x2 = [0,1,1,0];y2 = [1,1,1,1];z2 = [0,0,1,1];
side_color = [0,4,0.25,0.67];
h2 = fill3(x2,y2,z2,side_color,'FaceAlpha',0.5);
% 绘制正面
x3 = [1,1,1,1];y3 = [0,0,1,1];z3 = [0,1,1,0];
front_color = [0.172,0.475,0.27];
h3 = fill3(x3,y3,z3,front_color,'FaceAlpha',0.5);
% 添加图例
legend({'上面','侧面','正面'},'FontSize',12,'Location','eastoutside')
% 显示网格
grid on
hold off
# 指定观察到角度
view([140,23.5])
观察的角度可以先手动调整,然后获取观察的角度。
ax = get(gca);
ax.View
主要使用函数axes()
axes('Position',[0.28,0.62,0.28,0.25]); % 放置子图在主图中的位置
x4 = [1,0,0]; y4 = [0,1,0]; z4 = [0,0,1];
bevel_color = [0.82,0.15,0.47];
h4 = fill3(x4,y4,z4,bevel_color,'FaceAlpha',0.5);
如果只想显示部分图例,在绘图时可以用变量接受图像,然后在legend中指定显示的图例。如,在图中只想显示正面和小斜面的图例,则可以按照如下方式设置
legend([h3,h4],{'正面','小斜面'},'FontSize',12)
figure(1);clf;hold on
% 绘制上面
x1 = [0,1,1,0];y1 = [0,0,1,1];z1 = [1,1,1,1];
up_color = [0.7490,0.9490,0.9686];
h1 = fill3(x1,y1,z1,up_color,'FaceAlpha',0.5);
% 绘制侧面
x2 = [0,1,1,0];y2 = [1,1,1,1];z2 = [0,0,1,1];
side_color = [0,4,0.25,0.67];
h2 = fill3(x2,y2,z2,side_color,'FaceAlpha',0.5);
% 绘制正面
x3 = [1,1,1,1];y3 = [0,0,1,1];z3 = [0,1,1,0];
front_color = [0.172,0.475,0.27];
h3 = fill3(x3,y3,z3,front_color,'FaceAlpha',0.5);
% 指定观察到角度
view([140,23.5])
% 绘制子图
axes('Position',[0.28,0.62,0.28,0.25]); % 放置子图在主图中的位置
x4 = [1,0,0]; y4 = [0,1,0]; z4 = [0,0,1];
bevel_color = [0.82,0.15,0.47];
h4 = fill3(x4,y4,z4,bevel_color,'FaceAlpha',0.5);
view([140,23.5])
% 添加图例
legend([h3,h4],{'正面','小斜面'},'FontSize',12)
% 显示网格
grid on
hold off
标签:osi image 进入 get class 图例 方式 拖动 添加
原文地址:https://www.cnblogs.com/liuxiang2020/p/11192444.html