<div dir="ltr"><div><div><div><div><div><div><div>Well, as I understand you want to plot a function over an background image.<br><br></div>In the case the image pixel number fits the X-Y range of your graph it's rather simple.<br><br><pre style="font-family:Monospaced;font-style:normal"><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,0)">img</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(174,92,176);text-decoration:underline">ReadImage</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">IPD_PATH</span> <span style="color:rgb(92,92,92)">+</span> <span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">demos\teaset.png</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>

<span style="color:rgb(0,0,0)">rows</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">size</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">r</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">cols</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">size</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">c</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>

<span style="color:rgb(0,0,0)">img</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">rows</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(255,170,0)">:</span><span style="color:rgb(74,85,219)">)</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">0</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>        <span style="color:rgb(100,174,100);font-style:italic">// changing left lower image corner for checking purpose</span>
                            <span style="color:rgb(100,174,100);font-style:italic">            // change all 3 colour channels to get a black pixel</span>

<span style="color:rgb(174,92,176);text-decoration:underline">ShowColorImage</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>

<span style="color:rgb(0,0,0)">a</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(174,92,176);text-decoration:underline">gca</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">a</span><span style="color:rgb(92,92,92)">.</span><span style="color:rgb(170,170,170)">axes_visible</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(74,85,219)">[</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">on</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">on</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(188,143,143)">off</span><span style="color:rgb(188,143,143)">"</span><span style="color:rgb(74,85,219)">]</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">x</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(174,92,176);text-decoration:underline">linspace</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">1</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">600</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">600</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">y</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(188,143,143)">1</span><span style="color:rgb(92,92,92)">/</span><span style="color:rgb(188,143,143)">2</span><span style="color:rgb(92,92,92)">*</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(174,92,176);text-decoration:underline">plot</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">y</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">-</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">a</span><span style="color:rgb(92,92,92)">.</span><span style="color:rgb(170,170,170)">data_bounds</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(74,85,219)">[</span><span style="color:rgb(188,143,143)">0</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">0</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(0,0,0)">cols</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(0,0,0)">rows</span><span style="color:rgb(74,85,219)">]</span><span style="color:rgb(0,0,0)">;</span></pre>Two tricky things though:<br><br></div>1st: image coordinates (center of pixel) start at "1", hence there is a gap of 0.5 between image borders and the axes<br><br></div>2nd: it might become tricky if you want to have negative values on the axis.<br><br></div><div>Probably there is a way to shift the image to other position within the coordinate system?<br></div><div><br></div><div><br></div>So....not sure if this helps your purpose.<br><br></div>You could also switch "ON" / "OFF" the background image by access the children of the figure, such as:<br><pre style="font-family:Monospaced;font-style:normal"><span style="color:rgb(0,0,0)">IMGPlot</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(0,0,0)">a</span><span style="color:rgb(92,92,92)">.</span><span style="color:rgb(170,170,170)">Children</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(188,143,143)">2</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">; </span>  <span style="color:rgb(100,174,100);font-style:italic">// children(2) is the background in this case</span>
<span style="color:rgb(0,0,0)">IMGPlot</span><span style="color:rgb(92,92,92)">.</span><span style="color:rgb(170,170,170)">visible</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">off</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(100,174,100);font-style:italic"></span></pre><br></div><div>A complete other way would be to combine two images of same size.<br></div><div>Say...background image is img1.<br><br></div><div>your plot = img2.<br></div><div>Plot the graph and save the figure as a temporary image.<br><br></div><div>load img1<br></div><div>load temporary image<br></div><div><br></div><div>If size (img1) == size(img2)....You could use SIVP module to linear combine two images:<br><br><pre style="font-family:Monospaced;font-style:normal"><span style="color:rgb(0,0,0)">img_gray</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">double</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(174,92,176);text-decoration:underline">RGB2Gray</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">img2</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(50,185,185)">zeros</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">rows</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(0,0,0)">cols</span><span style="color:rgb(74,85,219)">)</span> <span style="color:rgb(92,92,92)">+</span> <span style="color:rgb(188,143,143)">255</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">img2</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">rows</span><span style="color:rgb(92,92,92)">/</span><span style="color:rgb(188,143,143)">2</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(255,170,0)">:</span><span style="color:rgb(74,85,219)">)</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(188,143,143)">0</span><span style="color:rgb(0,0,0)">;</span>
<span style="color:rgb(0,0,0)">img3</span> <span style="color:rgb(92,92,92)">=</span> <span style="color:rgb(174,92,176);text-decoration:underline">imlincomb</span><span style="color:rgb(74,85,219)">(</span> <span style="color:rgb(188,143,143)">0.5</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(0,0,0)">img_gray</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(188,143,143)">0.4</span><span style="color:rgb(0,0,0)">,</span> <span style="color:rgb(0,0,0)">img2</span><span style="color:rgb(74,85,219)">)</span>   // the values here define some kind of transparency.
<span style="color:rgb(174,92,176);text-decoration:underline">figure</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span> <span style="color:rgb(174,92,176);text-decoration:underline">ShowImage</span><span style="color:rgb(74,85,219)">(</span><span style="color:rgb(0,0,0)">img3</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(188,143,143)">'</span><span style="color:rgb(74,85,219)">)</span><span style="color:rgb(0,0,0)">;</span></pre><br><br></div>Best regards,<br></div>Philipp<br><div><div><br><br><div><div><div><div><div><br></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-08 17:49 GMT+01:00 Jan Åge Langeland <span dir="ltr"><<a href="mailto:j-lan@online.no" target="_blank">j-lan@online.no</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <br>
    <br>
    <div>On 08.02.2016 11:47,
      <a href="mailto:antoine.monmayrant@laas.fr" target="_blank">antoine.monmayrant@laas.fr</a> wrote:<br>
    </div>
    <blockquote type="cite">Hi
      everyone,
      <br>
      <br>
      I just failed at placing an image behind a plot.
      <br>
      I thought that would be easy:
      <br>
          - create a figure
      <br>
          - create an image uicontrol
      <br>
          - create an axis
      <br>
          - plot in the axis
      <br>
          - set axis.filled="off"
      <br>
      <br>
      Apparently I was wrong.
      <br>
      I did not find a way to overlap a plot with transparent background
      over my image.
      <br>
      It seems that the image is always above the plot no matter what
      order the uicontrol/axes where created.
      <br>
      I also tried to put both of them inside the same frame, but I did
      not work either.
      <br>
      <br>
      Any idea?
      <br>
      <br>
      <br>
    </blockquote>
    <br>
    <small><small>ShowImage(im,'J2');</small></small><br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:12.0"><span style="color:rgb(0,0,0)">b=newaxes();
b.filled = "off";
 plot(a)
</span><span style="color:rgb(0,0,0)"></span></pre>
    JÅ<br>
    <blockquote type="cite">_______________________________________________
      <br>
      users mailing list
      <br>
      <a href="mailto:users@lists.scilab.org" target="_blank">users@lists.scilab.org</a>
      <br>
      <a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a>
      <br>
      <br>
    </blockquote>
    <br>
  </div>

<br>_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">There we have the salad.</div>
</div>