Note that there are some explanatory texts on larger screens.

plurals
  1. POMatlab subplot disappears on reposition
    primarykey
    data
    text
    <p>I have the following function that is supposed to create subplots that are tightly spaced within a row, and distributed with spacing in each column. It also lets you set buffer sizes for the edges:</p> <pre><code>function fill_graph() for x=1:3 for y=1:3 ax = subplot(3,3,(x-1)*3+y); left_buffer = .05; right_buffer = .025; x_pos = left_buffer+(x-1)*(1/3*(1-left_buffer-right_buffer)); width = 1/3*(1-left_buffer-right_buffer); bottom_buffer = .1; top_buffer = .05; spacing=.07; height = (1/3)*(1-2*spacing-top_buffer-bottom_buffer); y_pos = bottom_buffer+(y-1)*(spacing+height); set(ax,'position',[x_pos,y_pos,width,height]) if x&gt;1 set(gca,'yTickLabel',''); ylabel(''); end if y&gt;1 || x~=2 xlabel('') end end end </code></pre> <p>When I run the function, the bottom row of plots and the leftmost plot on the middle row all disappear.</p> <p>I'm aware this probably has something to do with the fact that subplots will disappear when they overlap with one another, but regardless of how far apart I set the spacing, I can't get the bottom row to appear (the only way I've found is setting the bottom buffer above .34, which only works some of the time). I've tried switching 'position' to 'outerposition', which should make it so that none of them overlap, but that doesn't seem to work either.</p> <p>I have seen <a href="https://stackoverflow.com/questions/14273315/matlab-second-subplot-disappearing">Second subplot disappearing</a>, but when I specify the position in that manner (<code>subplot('position',x_pos,y_pos,width,height)</code>), it writes over the plots that are already there. If I place that code <i>before</i> I plot, the plots resize as soon as I issue the plot command.</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. 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