LoginSignup
27
24

More than 5 years have passed since last update.

matplotlibで座標軸を調整する

Posted at

自分で解説しようかと思いましたが、axisが便利すぎて特に言う事がないのでマニュアルの和訳を載せておきます。
nbviewerに表示例を載せましたのでついてに見てください。

matplotlib.pyplot.axis(*v, **kwargs)

Convenience method to get or set axis properties.
座標軸を設定したり設定を取得するのに便利な方法です。

Calling with no arguments:
引数無しで呼び出した場合:

axis()

returns the current axes limits [xmin, xmax, ymin, ymax].:
現在表示している座標の最大・最小を[xmin, xmax, ymin, ymax]の形式で返します。

axis(v)

sets the min and max of the x and y axes, with v = [xmin, xmax, ymin, ymax].:
v = [xmin, xmax, ymin, ymax]を引数として呼べはx,yの最大・最小をそれぞれ設定します。

axis('off')

turns off the axis lines and labels.:
座標軸を非表示にします。

axis('equal')

changes limits of x or y axis so that equal increments of x and y have the same length; a circle is circular.:
xあるいはyの上限・下限を調整して同じ座標値の増分が同じ長さになるように調整します。
円がちゃんと丸く表示されます。

axis('scaled')

achieves the same result by changing the dimensions of the plot box instead of the axis data limits.:
(上限・下限はそのままで)表示する領域を調整する事で('equal'の場合と)同じ効果を得ます。

axis('tight')

changes x and y axis limits such that all data is shown. If all data is already shown, it will move it to the center of the figure without modifying (xmax - xmin) or (ymax - ymin). Note this is slightly different than in MATLAB.:
全てのデータが見えるように最大・最小を変更します。もし既に見えている場合は(xmax - xmin)あるいは(ymax - ymin)を変えないように表示領域を中央に移動します。MATLABの場合と微妙に異なるので注意してください。

axis('image')

is ‘scaled’ with the axis limits equal to the data limits.:
データの最大・最小を使用した上でさらに'scaled'の効果を得ます。

axis('auto')

and:

axis('normal')

are deprecated. They restore default behavior; axis limits are automatically scaled to make the data fit comfortably within the plot box.
は廃止予定です。これらはデフォルトの設定を回復します。データがプロット領域にうまく入るようにします。

if len(*v)==0, you can pass in xmin, xmax, ymin, ymax as kwargs selectively to alter just those limits without changing the others.
len(*v)==0の場合はxmin, xmax, ymin, ymaxを選択的にキーワード引数として与える事ができます。この時与えられなかった設定はそのままで与えた設定を反映させられます。

The xmin, xmax, ymin, ymax tuple is returned

See also

xlim(), ylim()
For setting the x- and y-limits individually.

27
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
27
24