DerekDardzinski / vaspvis

A highly flexible and customizable library for visualizing electronic structure data from VASP calculations.
MIT License
30 stars 14 forks source link

Font #1

Open ding123456456 opened 3 years ago

ding123456456 commented 3 years ago

Hello, I would like to ask how to change the font type,Such as Song Ti, New Rome, etc.

Sunsky-ha0 commented 1 year ago

You can solve your problem in the following way:

  1. import matplotlib.font_manager for your preferred font:

    from matplotlib.font_manager import FontProperties from matplotlib import pyplot as plt font = FontProperties() font.set_family('serif')

    your favourite font and style

    font.set_name('Times New Roman') font.set_style('italic')

  2. add this font to output object:

    fig, ax = standard.dos_plain( folder=dos_folder_NA_AFM, output='dos_plain.png', linewidth=1, energyaxis='x', figsize=(6, 3), erange=[-5, 5], fontsize=12, log_scale=False) ax.set_ylabel('Density of States', fontproperties=font) plt.show()

  3. then your can see your font successfully!