Python plt.yticks does not work when specifying font on a logscale

Viewed 12

I have a piece of code for producing a plot that suddenly stopped working. The issue comes when I try to define the font for the yticks on a plot with a logscale.

Example:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
fig, ax = plt.subplots(figsize=(9,6))
ax.plot(np.arange(10),np.arange(10),color='green',linestyle='-',marker='.')
plt.xticks(font='Nimbus Roman',size=22)
plt.yticks(font='Nimbus Roman',size=22)
ax.set_yscale('log')

this produces an error:

ValueError: None is not a valid value for fontset; supported values are 'cm', 'dejavuserif', 'dejavusans', 'stix', 'stixsans', 'custom'

However, if I remove "font='Nimbus Roman'" fom the yticks part, or remove the logscale, the plot is plotted as expected. I also tried different fonts to no avail. The same error appears for the x-axis if I instead set that one to logscale.

I am using python3.9. This error does not occur in python3.8.6

0 Answers
Related