user3125347 - 9 months ago 53
Python Question

# matplotlib: Handling speech marks/quotation marks within ax.set_xlabel/ax.set_ylabel

I have a niche question here, I'm unable to find any guidelines specific to this. I was wondering if anyone knew how to correctly handle the following text for an axis label within the matplotlib package:

ax.set_xlabel(r'$1.005116" per pixel$')


The quotation marks are telling the class to simply type: 1.005116, stopping at the " (which correspond to the unit of arc second).

Does anyone know the correct method to handle this?

Taking advantage of the fact that you're using LaTeX:

ax.set_xlabel(r"$1.005116^{\prime\prime}$ per pixel")


(I think it looks better if the "per pixel" part is not in LaTeX math mode, but that's a stylistic issue.)