Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change font size and font style in plot_dispersion? #5

Closed
BianTieyuan opened this issue Jun 7, 2024 · 4 comments
Closed

How to change font size and font style in plot_dispersion? #5

BianTieyuan opened this issue Jun 7, 2024 · 4 comments

Comments

@BianTieyuan
Copy link

Hi developer,

I want to change line color, font size and font style in Phon.plot_dispersion. However I can only change line color via fig, ax = system.Phon.plot_dispersion(color='green') . I noticed that only few can be changed via this way:

help(system.Phon.plot_dispersion)

Help on method plot_dispersion in module mdapy.phonon:

plot_dispersion(units='THz', yticks=None, ylim=None, color=None, merge_kpoints=None) method of mdapy.phonon.Phonon instance
    This function can plot the phonon dispersion.
    
    Args:
        units (str, optional): units of frequency, selected in ['THz', '1/cm']. Defaults to "THz".
        yticks (list[float], optional): y axis ticks, such as [0, 10, 20]. Defaults to None.
        ylim (list[float], optional): y axis limitation, such as [0, 100]. Defaults to None.
        color (str | rgb turple, optional): line color, can be a str, such as 'r', '#729CBD', or a rgb turple, such as [125, 125, 125]. Defaults to None.
        merge_kpoints (list, optional): sometimes you want to merge two equalvalue points, such as [2, 3]. Defaults to None.
    
    Returns:
        tuple: (fig, ax) matplotlib figure and axis class.

But how to change font size and font style?

@mushroomfire
Copy link
Owner

Hi, @BianTieyuan, currently, you can directly utilize the source code to plot the results and make any desired modifications. Should you encounter any difficulties in modifying the code, I am available to assist you. Alternatively, you can await the upcoming version, which will unveil a comprehensive user interface for customizing the details of Matplotlib. Numerous features have been prepared for integration in the next release, but verifying them necessitates time. However, my current schedule is occupied with other commitments, hence the release of the next version may be delayed.

For font size and font style:

change code

fig, ax = set_figure(figsize=(10, 7.5), bottom=0.08, left=0.16, use_pltset=True, figdpi=150 )

to this:

mp.pltset(**{'font.serif':'Times New Roman', 'font.size':10})
fig, ax = set_figure(figsize=(10, 7.5), bottom=0.08, left=0.16, figdpi=150 )

@BianTieyuan
Copy link
Author

Thanks for your reply. @mushroomfire I extracted the data in Phon. dictionary and plot figure myself. The next version would be wonderful and I am looking forward your release.

@mushroomfire
Copy link
Owner

Hi, @BianTieyuan , try the newest version of mdapy. You can fully modify the details of the figure in plot_dispersion. See example in here.

@BianTieyuan
Copy link
Author

Hi, @BianTieyuan , try the newest version of mdapy. You can fully modify the details of the figure in plot_dispersion. See example in here.

The new features worked well. Thanks for the enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants