For the code below, how do I go about changing the font of all the labels and ticks to a font that is recognized by matplotlib.font_manager
? I wanted to change it to URW Palladio L
font, but I do not know the font family etc. as I tried this command:
plt.rcParams.update({'font.size': 18, 'font.family': 'serif', 'mathtext.fontset': 'URW Palladio L'})
but got the error:
ValueError: Key mathtext.fontset: 'URW Palladio L' is not a valid value for mathtext.fontset; supported values are ['dejavusans', 'dejavuserif', 'cm', 'stix', 'stixsans', 'custom']
Here is an example code:
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cbook
from matplotlib import cm
from matplotlib.colors import LightSource
import matplotlib.pyplot as plt
import numpy as np
# Set up plot
# Update the matplotlib configuration parameters:
#plt.rcParams.update({'font.size': 18, 'font.family': 'serif', 'mathtext.fontset': 'URW Palladio L'})
fig = plt.figure(figsize=(15, 12))
fig, ax = plt.subplots(subplot_kw=dict(projection='3d'), figsize=(15, 12))
ax.set_title(f'{graph_title}')
ax.set_xlabel('Frequency (Hz)', labelpad=20)
ax.set_ylabel('Time (s)', labelpad=20)
ax.set_zlabel('PSD Amplititude (dB/Hz)', labelpad=20)
ax.view_init(20, 20)
plt.show()
CodePudding user response:
Download the URW Palladio L .ttf file from here:
Graph with default font: