79708864

Date: 2025-07-21 09:57:07
Score: 1.5
Natty:
Report link

The fix to this was to use .replace in the following way:

fig, ax = plt.subplots()
ax.plot([1,2,3], [-50, 50, 100])
# Divide y tick labels by 10
ax.set_yticklabels([int(float(label.get_text().replace('−', '-'))/10) for label in ax.get_yticklabels()])

The reason behind this is that matplotlib returns a different ASCII character in .get_text() than the usual '-' which is recognised by the native float() function.enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: nernac