matplotlib format offset string

Leo*_*nth 1 python format plot matplotlib

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?

tmd*_*son 5

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

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()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明