2014-04-01 89 views
0

我有一個圖,其中在y標籤具有用於在它的數量級,其餘產生具有下面的行上標:matplotlib TEX標籤添加/刪除空格

# plt is acquired from matplotlib.pyplot 
# orderMagnitude is a variable taken from a different part of the code 
plt.ylabel('${\mathrm{Intensity (10^'+str(int(orderMagnitude))+')}}$') 

{\mathrm{..}}部分加入,因爲沒有它的整個文本將是斜體(實際數字除外)。我有該行現在似乎除去Y(強度)和開放之間的白色空間「(」然而,似乎在orderMagnitude後添加一些空白(見圖片)。

enter image description here

不有人知道爲什麼會發生這種情況嗎?

+0

使用'\ text {Intensity}'而不是'\ mathrm',在數學模式中也可以看到[here](http://www.personal.ceu.hu/tex/math.htm#spacing) –

回答

1

你不需要把整條線放在數學模式下,這是你陷入困境的一部分,特別是你將整個方程放在\ mathrm {}中,而不僅僅是{Intensity }。下面的內容可能會更好,並且不應該在最後得到額外的空白:

plt.ylabel('Intensity $(10^{' + str(int(orderMagnitude)) + '})$')