如何在我的Seaborn FactorPlot / FacetGrid中增加图例的字体大小?

时间:2018-05-06 15:10:36

标签: python seaborn

question的说明不适用于Seaborn FacetPlots。是否有可能让方法做同样的事情?

3 个答案:

答案 0 :(得分:1)

与链接的答案一样,您可以使用import kivy from kivy.app import App from kivy.core.window import Window from kivy.animation import Animation from kivy.uix.button import Button from kivy.config import Config Config.set('graphics', 'width', '300') Config.set('graphics', 'height', '100') Config.write() Window.size = (300, 100) class ButtonAnimation(Button): def __init__(self, **kwargs): Button.__init__(self, **kwargs) self.bind(on_press=self.start_animation) def start_animation(self, *args): anim = Animation(size=(300, 400), step=0.01) anim.start(Window) class MyApp(App): def build(self): root = ButtonAnimation(text='Press me') return root if __name__ == '__main__': MyApp().run() 设置属性(在本例中为图例的字体大小)。

关联问题的唯一区别是你需要为FacetGrid的每个轴做到这一点

setp

答案 1 :(得分:1)

如果您使用的是较新版本的matplotlib,则有一种更简单的方法来更改图例字体大小-

plt.legend(fontsize='x-large', title_fontsize='40')

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.legend.html

可能取决于您使用的matplotlib的版本。我正在使用2.2.3,它具有fontsize参数,但没有title_fontsize

答案 2 :(得分:0)

facetgrid图例不是轴的一部分,而是facetgrid对象的一部分。该图例仍然是标准的matplotlib图例,并且可以这样操作。

plt.setp(g._legend.get_title(), fontsize=20)

在哪里g是调用构造函数后返回的facetgrid对象。