Fwd: problems when plotting the current density map
Dear all, I'm having problems when formatting the current density map of a system. First, the colorbar doesn't appear even when colobar = True in the arguments of kwant.plotter.current. The other problem is related to the line color of the vectorial field. It seems that the program chooses the color corresponding to the intensities of the chosen color palette in each region of the map, even when the argument linecolor = 'certain color' is selected. For example, if I select cmap = 'jet', linecolor = 'black' in the arguments of kwant.plotter.current, the colors of the arrows will change from region to region according to the colors of the pallete instead of being black throughout the map. Is there an easy way to overcome these difficulties without modifying the plotter.py file? Best regards, Duarte José
Duarte José Pereira de Sousa wrote:
I'm having problems when formatting the current density map of a system. First, the colorbar doesn't appear even when colobar = True in the arguments of kwant.plotter.current.
Duarte, thanks for reporting this problem. I have fixed it for the (yet unreleased) maintenance branch of Kwant 1.3 [1]. For now, you can work around the problem as follows. Replace kwant.plotter.current(...) with kwant.plotter.current(..., show=False) followed by the cryptic from matplotlib import pyplot ax = pyplot.gca() pyplot.colorbar(ax.get_children()[-2], ax=ax) pyplot.show() That should make the colorbar appear. Of course, you can also use the current Kwant "stable" branch from git where the problem is fixed.
The other problem is related to the line color of the vectorial field. It seems that the program chooses the color corresponding to the intensities of the chosen color palette in each region of the map, even when the argument linecolor = 'certain color' is selected. For example, if I select cmap = 'jet', linecolor = 'black' in the arguments of kwant.plotter.current, the colors of the arrows will change from region to region according to the colors of the pallete instead of being black throughout the map.
Well observed! This behavior is intentional. Common matplotlib backends (like PDF) do not support arbitrarily thin lines, their minimum line width is 1. However, we want to be able to show arbitrarily thin lines, otherwise regions without current would be full of arrows (because of the numerically calculated current density is never quite zero). In order to work around this problem, for lines that should be thinner than 1, we keep the width at 1 and instead fade their color into the background color. We are very careful to do this in the perceptually correct way. (See function kwant.plotter._linear_cmap if you are interested.) From a certain viewing distance such "fake" thin lines look the same as "real" thin lines. If you still think that real solid lines would be useful, could you please explain why? If you are satisfied with my explaination, do you think that it should be added to the function's documentation? Cheers, Christoph [1] https://gitlab.kwant-project.org/kwant/kwant/commit/d16b3dfd31f4c5ae76c42fc4...
participants (2)
-
Christoph Groth
-
Duarte José Pereira de Sousa