pyplot tab character

matplotlib, python, tabs

Solution

I was surprised that `pylab.show` actually shows some spaces in place of your square. But `savefig` does not try to be smart and gives what you describe. Now, how many spaces does one tab take ? This question makes no sense. Is it 4 for you ? I will pick 4.2 for me. This means you need to decide how many spaces you want a tab to take in your text, i.e.:

fig = pylab.figure()
text = "test \t test".replace("\t", "    ")
fig.text(.1,.05, text, bbox=dict(facecolor='red', alpha=0.5))

Or, maybe you want to simply expand your tabs using "standard" conventions:

text = "test \t test".expandtabs()

Problem

I am trying to use the tab character in pyplot. However, the tab character is displaying a square, not the tab space I require. My code is: ``` fig = pl.figure() fig.text(.1,.05, "test \t test", bbox=dict(facecolor='red', alpha=0.5)) ``` Does anyone know why this doesn't work?

Original source