matplotlib format offset string

为君一笑 提交于 2020-04-11 12:00:30

问题


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?


回答1:


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()



来源:https://stackoverflow.com/questions/33748347/matplotlib-format-offset-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!