Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我有一个二维散点图,并且希望在原点显示图像(不是彩色正方形,而是实际图片)。有什么办法吗?
我还将绘制一个3-D球体,在该球体中我也希望在原点处显示图像。 回答: 对于二维绘图... 您正在寻找IMAGE功能。这是一个例子: img = imread('peppers.png'); %# Load a sample image scatter(rand(1,20)-0.5,rand(1,20)-0.5); %# Plot some random data hold on; %# Add to the plot image([-0.1 0.1],[0.1 -0.1],img); %# Plot the image ![]() 对于3D图... IMAGE功能不再适用,因为除非从正上方(即,沿Z轴正方向)观看轴,否则不会显示图像。在这种情况下,您将必须使用SURF函数在3-D中创建一个表面,然后将图像纹理映射到该表面上。这是一个例子: [xSphere,ySphere,zSphere] = sphere(16); %# Points on a sphere scatter3(xSphere(:),ySphere(:),zSphere(:),'.'); %# Plot the points axis equal; %# Make the axes scales match hold on; %# Add to the plot xlabel('x'); ylabel('y'); zlabel('z'); img = imread('peppers.png'); %# Load a sample image xImage = [-0.5 0.5; -0.5 0.5]; %# The x data for the image corners yImage = [0 0; 0 0]; %# The y data for the image corners zImage = [0.5 0.5; -0.5 -0.5]; %# The z data for the image corners surf(xImage,yImage,zImage,... %# Plot the surface 'CData',img,... 'FaceColor','texturemap'); ![]() 请注意,此表面固定在空间中,因此在旋转轴时,图像不一定总是直接面对相机。如果要使纹理贴图的表面自动旋转以使其始终垂直于相机的视线,则该过程将涉及更多的过程。 更多&回答... |
![]() |
![]() |