0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

matplotlibのxticksが見切れてしまう時の対処法

Posted at

matplotlibでグラフをpdf形式で保存しようとした時に、xticksが縦に長いと見切れてしまうことがあります。
test.png
そういう時は、savefigにおいてbbox_inchesを指定してあげると良いです。
画像の左下が(0,0)となり、(20,20)が右上に対応します。なので、xticksのラベルを見切れないように表示するには左下を(0,-5)のようにしてあげるとラベルまで余裕を持って表示されます。

from matplotlib.transforms import Bbox as BB
plt.savefig(image_name+'.pdf',bbox_inches=BB([[0,-5],[20,15]]))

test1.png

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?