Skip to content

Distortion of vertical axis labels that contain MathTeX (MacOSX backend) #2937

@pseudocubic

Description

@pseudocubic

When using the macosx backend, if MathTex is in a y-axis label, the resolution of the label is distorted. The horizontal axis labels display correctly. I tried a couple of other backends, and macosx seems to be the only one with this issue. I am using the current master branch, downloaded today.

From playing around with the source a bit, it seems like it is an issue introduced by #2665, specifically related to the draw_image_user_coords_device_size function added to src/_macosx.m. By changing back to the old function that was used, CGContextDrawImage, the problem seems to go away for me.

Below is some code that illustrates the issue.

import matplotlib as mpl
mpl.use('macosx')

import numpy as np
from matplotlib import pyplot as plt

x = np.linspace(0, 10, 11, endpoint=True)

fig, (ax1, ax2) = plt.subplots(2, 1)
fig.subplots_adjust(hspace=0.5)

y = np.random.rand(11)
ax1.plot(x, y)
ax1.set_xlabel('x label')
ax1.set_ylabel('y label')
ax1.set_title('plain labels')

y = np.random.rand(11)
ax2.plot(x, y)
ax2.set_xlabel('$x$ label')
ax2.set_ylabel('$y$ label')
ax2.set_title('labels with latex')

plt.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions