title: Is it possible to plot a graph into an image using matlab (or something else)?
body: <p>I have a picture file of a building (.png) that is in grayscale, and I have a script that generates a grid plot with color intensity of what section of the building someone spent time in during the day. The building is divided into a 3x3 grid and the plot corresponds accordingly. How can I plot this INTO the grayscale image and colorize it so that it matches the 3x3 plot? I have treid to follow this overlay technique but keep getting errors: <a href="http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/" rel="nofollow">http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/</a></p>
  
  <p>My grid plot script: </p>
  
  <pre><code>Data = [1:1:9; 1 2 3 4 5 6 7 8 9; 1 2 3 4 5 6 7 8 9 ;1 2 3 4 5 6 7 8 9;1 2 3 4 5 6 7 8 9];
  
  M = zeros(3,3);
  
   for ii = 2:size(Data,1)
        plot(ii-1)
        M(1:end) = Data(ii,:);
        imagesc(M)
        colormap jet
        shading flat %for an exact result
        % shading interp %for a smooth result 
  figure
    end
  </code></pre>
  
  <p>Any ideas or is this just not possible? I do have the image processing toolbox and if there is another program better suited for this I am happy to give it a shot. </p>
  
  <p>Edit: </p>
  
  <p>Here is the code I am trying to work with to get the blog post on transparency working: </p>
  
  <pre><code>BaseImage = imread('buildinglayout.png'); 
  imshow(BaseImage, 'InitialMag', 'fit');
  GridPlot = imread('5.png'); %output of grid plot generating script
  imshow(GridPlot,'InitialMag','fit')
  M(1:end) = Data(ii,:);
  h = imshow(M);
  hold off
  set(h,'AlphaData', GridPlot); 
  </code></pre>
  
  <p>And the error I get, though I am willing to bet I am not outlining the overlay properly at all regardless of this error:</p>
  
  <pre><code>Error using set
  Bad property value found.
  Object Name :  image
  Property Name :  'AlphaData'.
  
  Error in OverlayPlots (line 13)
  set(h,'AlphaData', GridPlot);
  </code></pre>