I am using the following as an axis label in matplotlib:
"Pixel Radiance ($W/m^2/\mu m$)"
But when I produce a graph with this as the y-axis label I get the image below, which has a strange space between the m^2 and the \mu which makes it look rather strange. How can I remove this strange space?
A reproducible example, without using any of my own data, is:
from matplotlib.pyplot import *
plot([1, 2, 3], [1, 2, 3])
ylabel("($W/{m^2}/\mu m$)")
You can use either plt. margins(x=0) or ax. margins(x=0) to remove all margins on the x-axis.
Hide the Whitespaces and Borders in Matplotlib Figure To get rid of whitespace around the border, we can set bbox_inches='tight' in the savefig() method. Similarly, to remove the white border around the image while we set pad_inches = 0 in the savefig() method.
Another way to change the visual appearance of plots is to set the rcParams in a so-called style sheet and import that style sheet with matplotlib. style. use . In this way you can switch easily between different styles by simply changing the imported style sheet.
You can use a negative space, \!
:
r"Pixel Radiance ($W/m^2\!/\mu m$)"
Incidentally, I'd recommend using raw-strings with LaTeX formulae, as that will prevent LaTeX commands (or parts of them) being interpreted as backslash-escapes: you probably wouldn't want \tau
ending up as a tab followed by au
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With