首页 > 解决方案 > 更改 uptplot 模块中的 figsize

问题描述

如何upsetplot在 Python 中更改模块中的 figsize?我看到有一个fig参数,但我不知道如何为它分配一个具有预定义大小的新图形。

标签: pythonfigurefigsizeupsetplot

解决方案


您可以使用 matplotlib 定义一个图形,然后将其传递给 uptplot。但是,除非设置了,否则图形大小会由 uptplot 自动重置element_size=None

所以请使用类似的东西:

from matplotlib import pyplot as plt
from upsetplot import generate_counts, plot

example = generate_counts()
fig = plt.figure(figsize=(10, 3))
plot(example, fig=fig, element_size=None)
plt.show()

感谢您启发开发有关此主题的示例:自定义元素大小和图形大小


推荐阅读