python - Matplotlib 标记注释字体大小在 PDF 中不会缩小到 1pt 以下
问题描述
我的代码中有两个 ax.annotate 语句。第一行文字我想变大。第二行文字应按比例缩小。
for i,j,k in zip(x_power,y_power,net_name_power):
ax.annotate(str(k), xy=(i, j), color='white', fontsize=1, weight='light', horizontalalignment='center', verticalalignment='bottom')
ax.annotate('{} , {}'.format(str(round(i,3)),str(round(j,3))), xy=(i, j), color='blue', fontsize=0.1, weight='light', horizontalalignment='center', verticalalignment='top')
ax.annotate 的字体大小不低于 fontsize=1。
在图像中,白色文本是 fontsize=1,而蓝色文本是 fontsize=0.1。但正如人们所看到的,两个文本的大小相同。我正在使用plt.savefig('output.pdf')以 PDF 格式转储绘图 。
我希望蓝色文本按比例缩小,以便整齐地放入红色圆形标记中。有人可以提出解决方案吗?
谢谢 !
解决方案
我相信最小字体点大小是 1 - 请参阅此处的源代码:
if size < 1.0:
_log.info('Fontsize %1.2f < 1.0 pt not allowed by FreeType. '
'Setting fontsize = 1 pt', size)
size = 1.0
您可以尝试使用字符串描述符:
例如:fontsize='xx-small'
font_scalings = {
'xx-small': 0.579,
'x-small': 0.694,
'small': 0.833,
'medium': 1.0,
'large': 1.200,
'x-large': 1.440,
'xx-large': 1.728,
'larger': 1.2,
'smaller': 0.833,
None: 1.0,
推荐阅读
- c++ - 在 C++ 中使用并行化的预期加速是多少(不是 OpenMp,而是
) - html - 如何在 HTML 中正确显示此代码段?
- php - 如何在 laravel 中使用数据透视表中的 3 个关系创建关系?
- javascript - 从 glMatrix 1 迁移到 glMatrix 2
- java - 如何初始化“if then”语句给出的变量?
- r - Installing tidyverse on Ubuntu 18.x & R 3.4.4/3.5.1
- swift - 是否可以在带有 openCv 的 iOS Swift 应用程序中使用 Realm 数据库?
- php - PHP,在动态循环周围添加 div 环绕
- database - 查找给定表 PostgreSQL 的直方图大小
- sql - 在 Excel 中运行 SQL 查询时出现日期错误