poster
2019-11-27, 07:35
<p>I am making a very simple scatter plot.</p>
<pre><code>pts = [1 1; -2 1];
scatter(pts(:, 1), pts(:, 2));
</code></pre>
<p>As we see, the <code>xlim</code> is automatically determined by MATLAB to be from <code>-2</code> to <code>1</code>, which is satisfactory to me.</p>
<p>What annoys me is that the origin <code>0</code> is not centered. That is the x-axis is asymmetric around <code>0</code>. In this particular example, I want the x-axis to be from <code>-2</code> to <code>2</code>.</p>
<p>I can surely find the largest absolute value, which is <code>2</code> in this case, and manually do <code>xlim([-2 2])</code>. Is there a more elegant way, like <code>axis center</code> in my imagination?</p>
More answer... (https://stackoverflow.com/questions/36174179/how-to-make-matlabs-xlim-auto-yet-symmetric-around-0)
<pre><code>pts = [1 1; -2 1];
scatter(pts(:, 1), pts(:, 2));
</code></pre>
<p>As we see, the <code>xlim</code> is automatically determined by MATLAB to be from <code>-2</code> to <code>1</code>, which is satisfactory to me.</p>
<p>What annoys me is that the origin <code>0</code> is not centered. That is the x-axis is asymmetric around <code>0</code>. In this particular example, I want the x-axis to be from <code>-2</code> to <code>2</code>.</p>
<p>I can surely find the largest absolute value, which is <code>2</code> in this case, and manually do <code>xlim([-2 2])</code>. Is there a more elegant way, like <code>axis center</code> in my imagination?</p>
More answer... (https://stackoverflow.com/questions/36174179/how-to-make-matlabs-xlim-auto-yet-symmetric-around-0)