【问题标题】:How to customise size of grouped boxplots [duplicate]如何自定义分组箱线图的大小[重复]
【发布时间】:2021-12-06 03:38:09
【问题描述】:

我有以下代码:

import matplotlib.pyplot as plt 
import seaborn as sns
import pandas as pd
import os
import matplotlib.font_manager as font_manager
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl


path = os.getcwd() + "/results/"



sns.set_theme(style="whitegrid")
df = pd.read_csv("C:/tmp/all2.txt")  

 
ax = sns.boxplot(x="cluster", y="val",
            hue="type", palette=["k", "w"],
            data=df,showfliers = False)

#sns.despine(ax=ax, trim=True, offset={'left':1,'right':1,'top':1,'bottom':1})

ax.set(ylabel='Number', xlabel='Clustered profiles')




font = font_manager.FontProperties(family='sans-serif',
                                   weight='bold',
                                   style='normal')
plt.legend(loc='best', frameon=False, prop=font)


plt.legend(loc='best', frameon=False, prop=font)
plt.xticks(weight='bold', fontname='sans-serif')
plt.yticks(weight='bold', fontname='sans-serif')
plt.xlabel("Clustered profiles", weight='bold', fontname='sans-serif', size=14)



plt.tight_layout()
plt.savefig(path + "/myoutput.pdf", dpi=250, transparent=False,   bbox_inches='tight', format="pdf")

我得到以下输出:

我正在尝试扩大我的输出,因为并非所有标签都可以读取;我不确定该怎么做。我尝试使用更高的 dpi,但它对我没有帮助。我错过了什么?

【问题讨论】:

  • 您可以增加 figsize,例如通过在创建情节之前调用plt.figure(figsize=(16,6))

标签: python seaborn


【解决方案1】:

感谢@JohanC 的评论,这里是解决方案;

plt.figure(figsize=(12,6))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-22
    • 2021-02-03
    相关资源
    最近更新 更多