pyplot tab character

0 votes
I want to use the tab character in pyplot. However, the tab character is displaying a square, not the tab space I want.

My code is as follows:

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

Can anyone tell me how to make it work?
Mar 19 in Python by ana1504.k
• 7,870 points
45 views

1 answer to this question.

0 votes
I see that pylab.show actually shows some spaces in place of your square. But savefig gives what you describe. So 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()

This might help you!
answered Mar 19 by SDeb
• 13,160 points

Related Questions In Python

0 votes
2 answers

Finding the index of a character in python string

You can use word.find('o') as well to ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
99 views
0 votes
1 answer

How to print first character of each word in upper case of a string in Python

You can use split() using space as ...READ MORE

answered Jun 1, 2018 in Python by george
• 200 points
1,791 views
0 votes
2 answers

Delete a character from pythons string

If you want to remove the 'J' ...READ MORE

answered Jun 12, 2018 in Python by anonymous
39 views
0 votes
1 answer
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

answered Aug 8, 2018 in Python by Priyaj
• 56,520 points
132 views
+1 vote
1 answer

How to handle Real-Time Matplotlib Plotting

To draw a continuous set of random ...READ MORE

answered Sep 26, 2018 in Python by Priyaj
• 56,520 points
2,042 views
0 votes
1 answer

How to increase plt.title font size?

Try the following : import matplotlib.pyplot as plt plt.figtext(.5,.9,'Temperature', ...READ MORE

answered Feb 11 in Python by SDeb
• 13,160 points
92 views
0 votes
1 answer

How to remove all characters before a specific character in Python?

Use re.sub. Just match all the chars ...READ MORE

answered Feb 27 in Python by SDeb
• 13,160 points
237 views
0 votes
1 answer

Why are Lists faster than character arrays for string concatenation?

It's true that in the list-append method, ...READ MORE

answered Jun 12 in Python by SDeb
• 13,160 points
21 views