2017-06-19 157 views
0

是否可以使用AnchoredText呈現文本粗體?粗體文本與AnchoredText(Python和Matplotlib)

plt.figure() 
ax = plt.subplot(3,1,1) 
anchored_text = AnchoredText("a", loc=2,borderpad=0.,frameon=False) 
ax.add_artist(anchored_text) 

我不覺得有什麼參數,我可以添加,使文本加粗。

回答

2

AnchoredText有一個參數prop它可以用來設置文本屬性。因此,您可以使用

AnchoredText("a", loc=2, prop=dict(fontweight="bold")) 

使文本變爲粗體。

完整的示例:

import matplotlib.pyplot as plt 
from matplotlib.offsetbox import AnchoredText 

plt.figure() 
ax = plt.subplot(3,1,1) 
anchored_text = AnchoredText("a", loc=2,borderpad=0.,frameon=False, 
          prop=dict(fontweight="bold")) 
ax.add_artist(anchored_text) 

plt.show() 

enter image description here

+0

這是完美的。謝謝。 – ymmx