2015-11-17 84 views
1

所以我正在尋找簡單地格式化matplotlib與已設置爲以科學記數法顯示刻度標籤的偏移字符串(至少這是我認爲它被稱爲,請參閱圖像) ,但範圍小於一個數量級(10的冪)。matplotlib格式偏移字符串

這裏是我所說的: enter image description here 基本上,我該如何讓它變大/變色?

回答

3

您可以使用ax.yaxis.get_offset_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() 

enter image description here

+0

感謝您對這樣一個簡潔的回答點。正是我在找什麼。 – LeoAnth