matplotlib: alignment of legend title

后端 未结 2 1367
南方客
南方客 2021-02-02 10:27

In matplotlib, how can I adjust the alignment of the legend title? It is always centered, but I need it to be left aligned with the legend box. I tried to change the al

2条回答
  •  轮回少年
    2021-02-02 10:32

    I think you need to displace the Text object, using the set_position((x, y)) method. The units of x and y are pixels, so you'll have to experiment with what values look right, or use a Transform. I'm not sure off hand which combination of Transforms might be most useful.

    So in short, something like this might work:

    l.get_title().set_position((-10, 0)) # -10 is a guess
    

提交回复
热议问题