繁体   English   中英

增加 Seaborn 标题的字体大小

[英]Increase the font size of a Seaborn title

我使用以下函数创建了一个散点图:

def plot_all_seaborn(x,y,types,x_axis, y_axis, title):
    tuples = only_floats(x,y,types)
    x,y,types_new = zip(*tuples)
    frame = pd.DataFrame({x_axis:x,y_axis:y,'Model':types_new})
    sns.relplot(data=frame,
                x=x_axis, 
                y=y_axis, 
                hue="Model", 
                style="Model",
                s=500
                ).set(title=title)

对于这个情节,我想增加表格的字体大小。 我尝试在set方法中添加font_size参数,但这不起作用。 如何放大标题?


基于此链接( 对 Seaborn 图中字体大小的精细控制),我尝试了:

def plot_all_seaborn(x,y,types,x_axis, y_axis, title):
    tuples = only_floats(x,y,types)
    x,y,types_new = zip(*tuples)
    frame = pd.DataFrame({x_axis:x,y_axis:y,'Model':types_new})
    b = sns.relplot(data=frame,
            x=x_axis, 
            y=y_axis, 
            hue="Model", 
            style="Model",
            s=500
            )
    b.set_title("Title",fontsize=20)
    plt.show()

但是,这会返回以下错误:

AttributeError: 'FacetGrid' object has no attribute 'set_title'

我认为您可以像这样实现您的结果;

def plot_seaborn(x,y,types,x_axis, y_axis, title):
    tuples = only_floats(x,y,types)
    x,y,types_new = zip(*tuples)
    frame = pd.DataFrame({x_axis:x,y_axis:y,'Model':types_new})
    sns.relplot(data=frame,
            x=x_axis, 
            y=y_axis, 
            hue="Model", 
            style="Model",
            s=500
            ).set_title(title, fontsize=23)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM