如何使用matplotlib编写版权信息

2 投票
3 回答
1046 浏览
提问于 2025-04-15 23:29

我正在用matplotlib制作一些图表,我想在图像的底部写上版权信息和我的网站地址。

比如说:

© ACME Corp www.example.com

有没有人知道我该怎么做呢?

3 个回答

1
plt.text(1,-1, 'Copyright: \xa9 Rafael Valero-Fernandez 2023', 
     horizontalalignment='right',
     verticalalignment='bottom')

看起来是这样的:

在这里输入图片描述

我这边的所有代码:

# library
import matplotlib.pyplot as plt
from matplotlib_venn import venn3

name_file = "venn_diagram_purpose"

# Use the venn3 function
# Make a Basic Venn
plt.close('all')

v = venn3(subsets=(1, 1, 1, 1, 1, 1, 1), 
          set_labels = ('Skills', 
                        'Opportunity',
                        'Interest'))
v.get_label_by_id('111').set_text('Destiny')
v.get_label_by_id('100').set_visible(False)
v.get_label_by_id('010').set_visible(False)
v.get_label_by_id('001').set_visible(False)
v.get_label_by_id('110').set_visible(False)
v.get_label_by_id('011').set_visible(False)
v.get_label_by_id('101').set_visible(False)
""" v.get_patch_by_id('111').set_color('blue')
v.get_patch_by_id('100').set_color('white')
v.get_patch_by_id('010').set_color('white')
v.get_patch_by_id('001').set_color('white')
v.get_patch_by_id('110').set_color('white')
v.get_patch_by_id('011').set_color('white')
v.get_patch_by_id('101').set_color('white') """
# Add title and annotation
plt.title("Where is your destiny?")

plt.text(1,-1, 'Copyright: \xa9 Rafael Valero-Fernandez 2023', 
     horizontalalignment='right',
     verticalalignment='bottom')


plt.show()
plt.savefig(f'{name_file}.png')
3

要在图形的坐标轴区域外写文字,可以使用 figtext 这个功能。

0

不确定这是否能回答你的问题,但你可以用下面的代码在图形中放入任何文本:

 text(x, y, s, fontdict=None, **kwargs)

一些字体的例子可以在 这里 找到。

撰写回答