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, 2019 in Python by ana1504.k
• 7,890 points
267 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, 2019 by SDeb
• 13,250 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
269 views
+1 vote
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
4,632 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
68 views
0 votes
1 answer

What's the right way to concatenate files and appending the New Line character in Python? Text or binary mode?

It seems like you're using the wrong ...READ MORE

answered Nov 13, 2018 in Python by Anirudh
• 2,080 points

edited Dec 14, 2018 by Anirudh 231 views
+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
• 57,530 points
276 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
• 57,530 points
8,405 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, 2019 in Python by SDeb
• 13,250 points
295 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, 2019 in Python by SDeb
• 13,250 points
5,163 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, 2019 in Python by SDeb
• 13,250 points
47 views