python - Matplotlib 中表格周围的空格
问题描述
我想使用 Matplotlib 创建一个表格来给出工程计算的结果。但是,我无法摆脱桌子周围的空白。我希望 - 几乎 - 表格周围没有空格,因此用户可以复制 png 并在他们的报告中使用它。
import matplotlib.pyplot as plt
FS_VRM2002 = 1.4
FS_CTRS2013 = 1.3
FS_PSS2017 = 1.2
FS_A2012 = 1.1
FS_KLVF2017 = 1.0
FS_list = []
Name_list = []
if True:
FS_list.append(FS_VRM2002)
Name_list.append("Vermeer, Ruse & Marcher (2002)")
if True:
FS_list.append(FS_CTRS2013)
Name_list.append("Carranza-Torres et. al. (2013)")
if True:
FS_list.append(FS_PSS2017)
Name_list.append("Paternesi, Schweiger & Scarpelli (2017) ")
if True:
FS_list.append(FS_A2012)
Name_list.append("Anagnostou (2012) ")
if True:
FS_list.append(FS_KLVF2017)
Name_list.append("Kavvadas, Litsas, Vazaios & Fortsakis (2017)")
FS_list_table = []
for i, j in enumerate(FS_list):
FS_list_table.append([j])
fig, ax = plt.subplots(figsize=(6,5))
table = ax.table(
cellText=FS_list_table,
colLabels=["Factor of Safety"],
rowLabels=Name_list,
loc="center",
cellLoc="center",
colWidths=[0.2],
rowLoc="center",
)
ax.axis("tight")
ax.axis("off")
结果:
您可以在此处获得复制版本: https ://share.streamlit.io/akrolsmir/streamlit-snippet/main?snippet_id=OEmnTTRC
解决方案
推荐阅读
- c++ - 对 std::vector 进行排序
按降序排列特定坐标 - python - 增加X轴数字之间的空间
- python - Python CSV 写入 ;;;;;; 到每一行
- python - python tkinter 无法在画布上实现提升方法
- javascript - 按字母的每个新实例拆分字符串
- kubernetes - 何时在 kubernetes 上删除 PersistentVolume?
- azure-sql-database - Azure SQL - 从 Azure 文件而不是 Blob 批量插入
- matplotlib - seaborn 风格的 whitegrid 没有蜱虫
- java - 表中的列不存在(spring boot jpa,单向 OneToMany)
- javascript - 如何使用带有 Vanilla JS、HTML 和 CSS 的 Electron 制作 SPA