We use plotly for interactive plotting. Data for plotly is obtained using `pivotpy.iplots.create_rgb_lines`.
import os
import pivotpy as pp
os.chdir('E:/Research/graphene_example/ISPIN_1/bands')
fig=iplot_rgb_lines(mode='markers',elim=[-10,10],orbs=[[0],[1],[2,3]],labels=['s','p<sub>z</sub>','p<sub>x</sub>+p<sub>y</sub>'],
ktick_inds=[0,30,60,-1],ktick_vals=['Γ','M','K','Γ'],Fermi=-2.7735,max_width=16)
iplot2html(fig,modebar=False)
Creating a grid plot using iplot_rgb_lines
- Here is a workaround if you want to plot multiple axes like matplotlib. You can add traces to plotly's
make_subplots
object by gettingdata=iplot_rgb_lines().data
andlayout=iplot_rgb_lines().layout
objects. See example below:
import plotly.graph_objects as go
from IPython.display import HTML
import pivotpy.iplots as ips
import os
from plotly.subplots import make_subplots
os.chdir('E:/Research/graphene_example/ISPIN_1/bands')
inds=[0,30,60,-1]
lbs=['Γ','M','K','Γ']
kargs=dict(mode='markers',elim=[-10,10],ktick_inds=inds,ktick_vals=lbs)
fig5 = make_subplots(rows=2, cols=2,shared_yaxes=True,shared_xaxes=True,
horizontal_spacing=0.08,
vertical_spacing=0.1,
subplot_titles=['s','pz','py','s,p,d'],
column_widths=[1,2],
row_heights=[1,2],
y_title='Energy (eV)'
)
[fig5.add_trace(trace,row=1,col=1) for trace in ips.iplot_rgb_lines(orbs=[0,[],[]],**kargs).data]
[fig5.add_trace(trace,row=1,col=2) for trace in ips.iplot_rgb_lines(orbs=[[],[1],[]],**kargs).data]
[fig5.add_trace(trace,row=2,col=1) for trace in ips.iplot_rgb_lines(orbs=[[],[],[2]],**kargs).data]
last=ips.iplot_rgb_lines(**kargs)
[fig5.add_trace(trace,row=2,col=2) for trace in last.data]
fig5.update_layout(width=600,height=400,font=last.layout.font,margin=dict(r=10,l=10,t=40,b=40))
fig5.update_xaxes(last.layout.xaxis)
last.layout.yaxis.title=''
fig5.update_yaxes(last.layout.yaxis)
iplot2html(fig5,modebar=False)
Click on gridplot.html to see the plot generated from above code.
Using _collect_dos
in Plotly
- A function similar to
splot_dos_lines
is created in plotly below. Plotly will reduce number of parameters and you are able to tweek those parameters interactively in graph.
import pivotpy as pp
fig=iplot_dos_lines(path_evr='E:/Research/graphene_example/ISPIN_2/dos/vasprun.xml',vertical=False,fill_area=True,elements=[[0],[1],[]],orbs=[0,1,[2,3]],labels=['C1-s','C2-p<sub>z</sub>','None-p<sub>x</sub>+p<sub>y</sub>'],figsize=(700,550),colormap='RGB')
iplot2html(fig,modebar=False)