Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>For 2-D plots...</h2> <p>The function <a href="http://www.mathworks.com/help/techdoc/ref/image.html" rel="noreferrer">IMAGE</a> is what you're looking for. Here's an example:</p> <pre><code>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 </code></pre> <p><img src="https://i.stack.imgur.com/sKh07.png" alt="alt text"></p> <p><br></p> <h2>For 3-D plots...</h2> <p>The <a href="http://www.mathworks.com/help/techdoc/ref/image.html" rel="noreferrer">IMAGE</a> function is no longer appropriate, as the image will not be displayed unless the axis is viewed from directly above (i.e. from along the positive z-axis). In this case you will have to create a surface in 3-D using the <a href="http://www.mathworks.com/help/techdoc/ref/surf.html" rel="noreferrer">SURF</a> function and texture map the image onto it. Here's an example:</p> <pre><code>[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'); </code></pre> <p><img src="https://i.stack.imgur.com/8j3Bd.png" alt="alt text"></p> <p>Note that this surface is fixed in space, so the image will not always be <em>directly</em> facing the camera as you rotate the axes. If you want the texture-mapped surface to automatically rotate so that it is always perpendicular to the line of sight of the camera, it's a much more involved process.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload