matplotlib格式偏移字符串 [英] matplotlib format offset string

查看:187
本文介绍了matplotlib格式偏移字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我希望简单地格式化matplotlib所放置的偏移量字符串(至少这就是我认为的名称,请参见图片)以及已设置为以科学计数法显示刻度标签的轴,但是范围小于一个数量级(10的幂).

So I am looking to simply format the offset string (at least that is what i think it is called, see image) that matplotlib places along with an axis that has been set to show tick labels in scientific notation, but where the range is less than one order of magnitude (power of 10).

这是我在说的: 本质上,如何使它变大/变色?

here is what I am talking about: Essentially, how do I make it bigger/coloured?

推荐答案

,您可以使用ax.yaxis.get_offset_text()访问偏移文本.然后,您可以在该Text对象上设置大小和颜色.例如:

you can use ax.yaxis.get_offset_text() to access the offset text. You can then set the size and color on that Text object. For example:

import matplotlib.pyplot as plt
import numpy as np

fig,ax = plt.subplots()
ax.plot(range(10),np.linspace(0,1e11,10))

offset_text = ax.yaxis.get_offset_text()

offset_text.set_size(20)
offset_text.set_color('red')

plt.show()

这篇关于matplotlib格式偏移字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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