
Dear kwant community, Is there any way to change the color limits in kwant.plotter.plot? I use the site_color in kwant.plotter.plot to map my data on a 3D system. In contrast to kwant.plotter.map, there is no vmin/vmax option. I know that I can assign the figure to a subplot with ax. But I haven't found a way to create a colorbar or set the color limits with this option, because I lack a mappable. Has anyone figured out how to do this? (or if it is possible) Thanks, Jannis

HI Jannis, Could you please provide a small script for the problem you want to solve? Adel

Hi Adel, I want to map the local density of states at E=0 on a 3D structure. vector_factory = kwant.kpm.LocalVectors(syst) local_dos = kwant.kpm.SpectralDensity(syst, num_vectors=num_vectors, vector_factory=vector_factory, mean=False, rng=0,params=params) ldos_at_zero = local_dos(energy=0) kwant.plotter.plot(syst, site_color=ldos_at_zero , cmap="hot", site_size=0.5, colorbar=True) The code above works, but I want to change the limits of the colorbar manually. Jannis Am 11.07.2020 um 19:59 schrieb abbout.adel@gmail.com:
HI Jannis,
Could you please provide a small script for the problem you want to solve?
Adel

Hi Jannis, you have to do this by hand, like so ``` fig = plt.figure() ax = fig.add_subplot() cmap = cm.magma # your cmap site_color = np.ones(len(syst.sites())) # or your colors vmin = 1 vmax = 2 # your color bounds norm = colors.Normalize(vmin=vmin, vmax=vmax) normalized_colors = norm(site_color) # cmap(normalized_colors) return the colors as an RGBA array kwant.plot(syst.finalized(), site_color=cmap(normalized_colors), ax=ax) mappable = cm.ScalarMappable(cmap=cmap, norm=norm); fig.colorbar(mappable); ``` Best, Pablo

Hi Pablo, thanks a lot, it works. Best, Jannis Am 17.07.2020 um 16:17 schrieb pablo.perez.piskunow@gmail.com:
Hi Jannis,
you have to do this by hand, like so
``` fig = plt.figure() ax = fig.add_subplot()
cmap = cm.magma # your cmap site_color = np.ones(len(syst.sites())) # or your colors vmin = 1 vmax = 2 # your color bounds norm = colors.Normalize(vmin=vmin, vmax=vmax) normalized_colors = norm(site_color) # cmap(normalized_colors) return the colors as an RGBA array kwant.plot(syst.finalized(), site_color=cmap(normalized_colors), ax=ax) mappable = cm.ScalarMappable(cmap=cmap, norm=norm); fig.colorbar(mappable); ```
Best, Pablo
participants (3)
-
abbout.adel@gmail.com
-
Jannis
-
pablo.perez.piskunow@gmail.com