pwtools.kpath.plot_dis

pwtools.kpath.plot_dis(path_norm, freqs, special_points_path=None, show_coords=None, dos=None, ax=None, ylim=None, **kwargs)[source]

Plot dispersion.

See bin/plot_dispersion.py for a usage example. This lives here (and not in pwscf) b/c it is not PWscf-specific. It can be used for any dispersion data (band structure).

See read_matdyn_freq() for how to get freqs in the case of phonon dispersions.

This function is a convenience function, which can even plot the DOS as well. We do not expose many matplotlib parameters here. If you want to tweak your plot much, then operate on the returned fig, ax (dispersion) and axdos (dos), or copy and hack the function, which might be actually the easiest way.

Parameters:
  • path_norm (array (nks,)) – x-axis with cumulative norms of points along the k-path, see get_path_norm()

  • freqs (array (nks, nbnd)) – nbnd frequencies for each band at each k-point

  • special_points_path (optional, SpecialPointsPath instance) – used for pretty-printing the x-axis (set special point labels)

  • show_coords ('cart', 'frac', None) – Show the cartesian or fractional coordinates of special points in the x-axis label, on neither if None.

  • dos (array (N,2) or None) – array with phonon dos to plot: dos[:,0]=freq, dos[:,1]=phdos

  • ax (matplotlib AxesSubplot (e.g. from fig,ax=pwtools.mpl.fig_ax())) – automatically created if None

  • ylim (tuple (2,)) – frequency axis limits

  • **kwargs (keywords) – passed to plot()

Returns:

  • fig, ax, axdos

  • fig (matplotlib Figure to ax)

  • ax (matplotlib AxesSubplot with dispersion)

  • axdos (matplotlib AxesSubplot with dos, or None if dos=None)

Examples

>>> spp = kpath.SpecialPointsPath(ks=np.array([[0,0,0], [1.5,0,0], [2.3,0,0]]),
                                  symbols=['A', 'B', 'C'])
>>> path_norm = np.linspace(0,2.5,100)
>>> freqs = np.random.rand(100,5)*500
>>> # create fig,ax inside, returned axdos=None
>>> fig,ax,axdos = kpath.plot_dis(path_norm, freqs, spp)
>>> # pass ax from outside, returns fig,ax but we don't use that b/c ax
>>> # is in-place modified
>>> fig,ax = mpl.fig_ax()
>>> kpath.plot_dis(path_norm, freqs, spp, ax=ax)
>>> # plot also DOS
>>> dos = np.empty((30,2)); dos[:,0]=np.linspace(0,500,30); dos[:,1]=rand(30)
>>> fig,ax,axdos = kpath.plot_dis(path_norm, freqs, spp, dos=dos)