在 matplotlib 中更改字体宽度 [英] Change font width in matplotlib

查看:58
本文介绍了在 matplotlib 中更改字体宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用plt.text绘制在水平方向上不同程度拉伸或压缩的字母.我以为'stretch'选项可以做到这一点,但它不会改变任何东西:

I trying to use plt.text to plot letters that are variously stretched or squeezed in the horizontal direction. I thought the 'stretch' option would do that, but it doesn't change anything:

import matplotlib.pyplot as plt

plt.text(1,1, 'A', stretch=100)

plt.show()

我为拉伸使用什么值似乎并不重要,结果看起来总是一样的.

It doesn't seem to matter what value I use for stretch, the result always looks the same.

推荐答案

我尝试使用 mpl.rcParams['font.stretch'] = 1000 指定拉伸,但根据 官方文档,似乎 font.stretch 尚未实现(重点是我的):

I tried specifying the stretch using mpl.rcParams['font.stretch'] = 1000 but as per the official docs, it seems font.stretch is not yet implemented (emphasis mine):

font.stretch 属性有 11 个值:ultra-condensed、extra-condensed、condensed、semi-condensed、normal、semi-expanded、expanded、extra-expanded、ultra-expanded、wider、narrower.该属性当前未实现.

The font.stretch property has 11 values: ultra-condensed, extra-condensed, condensed, semi-condensed, normal, semi-expanded, expanded, extra-expanded, ultra-expanded, wider, and narrower. This property is not currently implemented.

这篇关于在 matplotlib 中更改字体宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆