MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   How to make MATLAB's xlim auto yet symmetric around 0? (https://www.labfans.com/bbs/showthread.php?t=22180)

poster 2019-11-27 07:35

How to make MATLAB's xlim auto yet symmetric around 0?
 
<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>



[url=https://stackoverflow.com/questions/36174179/how-to-make-matlabs-xlim-auto-yet-symmetric-around-0]More answer...[/url]


所有时间均为北京时间。现在的时间是 19:47

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.