LoginSignup
2
3

More than 5 years have passed since last update.

Python matplotlib 凡例の位置とアルファ値の変更

Last updated at Posted at 2018-03-03

まずは作例を.

fig_hs_bc4.png

凡例のアルファ値(透明度)の指定は下の記事からいただきました.

https://qiita.com/hnii2006/items/2db5312fe4a4365734d0

凡例の位置はbbox_to_anchor=(xl,yl),loc='center'で調整可能.
ただし,グラフの左下が(0,0),右上が(1,1)の座標系なので,それを考慮した座標計算が必要.作例の図では,下のコードのように,凡例描画のx座標をグリッドの真ん中に持ってくるようにしている.

    xl=(0.5*(np.min(x)+np.max(x))-xmin)/(xmax-xmin)
    yl=(0.5*(np.min(y)+np.max(y))-ymin)/(ymax-ymin)
    plt.legend(bbox_to_anchor=(xl,yl),loc='center').get_frame().set_alpha(1.0)

以 上

2
3
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
2
3