4
$\begingroup$

I am using Pyprocar to plot my band structure. However I cannot change color even modified the 'color' parameter. I tried to change color of their examples referred to Fe band structure but did not work. Here is my code:

import pyprocar
import os
pyprocar.bandsplot(code='vasp', dirname = band_dir,outcar='OUTCAR', mode='plain', show=True, atoms=atoms,spins=[0],fermi=-0.1,color='red') 

The figure showed this, band was still blue. I cannot figure out reasons. Hope someone could help me. enter image description here

I now know how to change color and linewidth in plain mode with the help of ChatGPT...

import pyprocar
import os
ebs_plot= pyprocar.bandsplot(code='vasp', dirname = band_dir,outcar='OUTCAR', mode='plain', show=True, atoms=atoms,spins=[0],fermi=-0.1) 

for handle in ebs_plot2.handles:
    handle[0].set_color('k')
    handle[0].set_linewidth(0.5)

However, when plotting projection band structure in 'parametric' and 'scatter' mode, the added code won't work. Can somebody help ?

$\endgroup$

1 Answer 1

1
$\begingroup$

Changing band color in plain mode

Can be achieved by setting the color argument in the bandsplot function

import pyprocar
data_dir = pyprocar.download_example(save_dir='',
                             material='Fe',
                             code='vasp',
                             spin_calc_type='non-spin-polarized',
                             calc_type='bands')
pyprocar.bandsplot(code='vasp', dirname = data_dir, mode='plain', 
show=True, atoms=[0],spins=[0],fermi=-0.1,color='red')

This produces a plot with red band lines like below

enter image description here

Changing band color and line width in parametric and scatter mode

The Pyprocar library doesn't directly support changing the color and linewidth of bands in the projection band structure plots in 'parametric' and 'scatter' modes. However, you can still achieve this by modifying the code of the library or by customizing the plots after they have been generated.

Below is the related piece of code which you could tweak. So the weights for the color and linewidth are calculated as below.

So you could modify the parent function: bandsplot to have two extra arguments width_weights and color_weights and could use them instead of the computed ones.

weights = ebs_plot.ebs.ebs_sum(atoms=atoms, principal_q_numbers=[-1], orbitals=orbitals, spins=spins)
        if plot_opt['weighted_color']['value']:
            color_weights = weights
        else:
            color_weights = None
        if plot_opt['weighted_width']['value']:
            width_weights = weights
        else:
            width_weights = None
        color_mask = projection_mask
        width_mask = projection_mask
        if mode == "parametric":
            ebs_plot.plot_parameteric(
                color_weights=color_weights,
                width_weights=width_weights,
                color_mask=color_mask,
                width_mask=width_mask,
                spins=spins
                )
        elif mode == "scatter":
            ebs_plot.plot_scatter(
                color_weights=color_weights,
                width_weights=width_weights,
                color_mask=color_mask,
                width_mask=width_mask,
                spins=spins)
$\endgroup$
1
  • $\begingroup$ Thanks for your answer! The 'color' now can be changed in the newest version of Pyprocar. $\endgroup$ Commented Aug 29, 2023 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .