Dear Jingda,

The colorbar can be added in the usual way with matplotlib but admittedly the possibility of doing so is a bit hidden.

Note that the function "plot_exciton_2D_ax" accepts all the argument (kwargs) the pyplot.scatter() function of matplotlib would accept. Also, "plot_exciton_2D_ax" returns the ax and plot objects by default.

Therefore, it is sufficient to modify your script this way:

Code: Select all

```
if Kspace_Plot:
fig = plt.figure(figsize=(10,10),dpi=300)
ax = fig.add_axes( [ 0, 0, 1, 1 ])
ax, PLOT = yexc.plot_exciton_2D_ax(ax,states,mode='hexagon',limfactor= 1,scale= 1100,cmap="YOUR_CMAP_NAME") #### added cmap keywork
plt.colorbar(PLOT) ##### plot colorbar for object PLOT
plt.savefig('A.jpg')
```

Keep in mind that by adding the colorbar you change the actual plot dimensions, so you either have to increase figsize or reduce the scale parameters for the plot markers in order to have the same visualization. In general, all matplotlib plot options and "ax" methods apply to this plot and you can add them to the script just as you would for any matplotlib plot.

Cheers,

Fulvio

Dr. Fulvio Paleari

S3-CNR Institute of Nanoscience and MaX Center

Modena, Italy