plt.rcParams[‘axes.unicode_minus‘] = False #解决保存图像是负号‘ 这句话是什么意思?

plt.rcParams是一个字典,它存储了matplotlib的配置参数,用于控制图形的外观和行为。⁴

plt.rcParams[‘axes.unicode_minus’]是一个配置参数,它决定了坐标轴上负号的显示方式。

如果设置为True(默认值),则使用Unicode字符U+2212表示负号,这个字符比ASCII字符U+002D更长。³

如果设置为False,则使用ASCII字符U+002D表示负号,这个字符可能与减号混淆。³

有时候,使用Unicode负号会导致图像保存时出现乱码或无法显示的问题,所以可以将plt.rcParams[‘axes.unicode_minus’]设置为False来解决。¹²

Unicode字符U+2212和ASCII字符U+002D的样子如下:

Unicode负号:−
ASCII负号:-

您可以看到,Unicode负号比ASCII负号更长一些。

2023/3/19(1) Customizing Matplotlib with style sheets and rcParams. https://matplotlib.org/stable/tutorials/introductory/customizing.html 访问时间 2023/3/19.
(2) Unicode minus — Matplotlib 3.7.1 documentation. https://matplotlib.org/stable/gallery/text_labels_and_annotations/unicode_minus.html 访问时间 2023/3/19.
(3) plt.rcParams[‘font.sans-serif‘] = [‘SimHei‘] 和plt.rcParams[‘axes … https://blog.csdn.net/Fwuyi/article/details/123084642 访问时间 2023/3/19.
(4) Python 之 plt.rcParams[] - 赏尔 - 博客园. https://www.cnblogs.com/shanger/p/13021452.html 访问时间 2023/3/19.
(5) matplotlib.pyplot.rc — Matplotlib 3.7.1 documentation. https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.rc.html 访问时间 2023/3/19.

  • 11
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

irrationality

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值