Why does the below code delete space when printed on figure fig
?
fig = plt.figure(figsize=(15,5))
TestStr= "$* This is a Test$"
print(TestStr) # Returns : * This is a Test
text = fig.text(0.30, 0.005, BoFaSpread,horizontalalignment='center', wrap=True)# Displays on fig : *ThisisaTest
CodePudding user response:
CodePudding user response:
Because it is rendered as Markdown Math
or Katex
as inline math block.
Following is syntax for inline math block in markdown: $equation$
$* This is a Test$
in markdown will be *ThisisaTest
hence there's no space.
You can use space as per markdown \>
in your text. So you can do one of the following:
plt.title("$*This \> is \> Text*$") # \> will add space
plt.title("$\\it{This \> is \> Text}$") # \it is markdown function for italic text
And you can also passed keyword arg of fontstyle="italic"
also
plt.title("This is Text", fontstyle="italic")
I hope this solved your issue.