Skip to content
Snippets Groups Projects
Commit a88cdf0f authored by Joseph Weston's avatar Joseph Weston
Browse files

explain the usecases for 'density' and 'map'

Also add reference documentation for 'density'.
parent 3bfa10c3
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ Plotting routines ...@@ -11,6 +11,7 @@ Plotting routines
plot plot
map map
density
current current
bands bands
spectrum spectrum
...@@ -22,6 +23,7 @@ Helper functions ...@@ -22,6 +23,7 @@ Helper functions
:toctree: generated/ :toctree: generated/
interpolate_current interpolate_current
interpolate_density
sys_leads_sites sys_leads_sites
sys_leads_hoppings sys_leads_hoppings
sys_leads_pos sys_leads_pos
......
...@@ -124,7 +124,7 @@ is the square matrix referred to previously. ...@@ -124,7 +124,7 @@ is the square matrix referred to previously.
Below we can see colorplots of the above-calculated quantities. The array that Below we can see colorplots of the above-calculated quantities. The array that
is returned by evaluating a `~kwant.operator.Density` can be used directly with is returned by evaluating a `~kwant.operator.Density` can be used directly with
`kwant.plotter.map`: `kwant.plotter.density`:
.. image:: /code/figure/spin_densities.* .. image:: /code/figure/spin_densities.*
......
...@@ -1214,6 +1214,11 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None, ...@@ -1214,6 +1214,11 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None,
calling `~kwant.plotter.mask_interpolate` and show this pixmap using calling `~kwant.plotter.mask_interpolate` and show this pixmap using
matplotlib. matplotlib.
This function is similar to `~kwant.plotter.density`, but is more suited
to the case where you want site-level resolution of the quantity that
you are plotting. If your system has many sites you may get more appealing
plots by using `~kwant.plotter.density`.
Parameters Parameters
---------- ----------
sys : kwant.system.FiniteSystem or kwant.builder.Builder sys : kwant.system.FiniteSystem or kwant.builder.Builder
...@@ -1269,6 +1274,10 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None, ...@@ -1269,6 +1274,10 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None,
- When plotting a system on a square lattice and `method` is "nearest", it - When plotting a system on a square lattice and `method` is "nearest", it
makes sense to set `oversampling` to ``1``. Then, each site will makes sense to set `oversampling` to ``1``. Then, each site will
correspond to exactly one pixel. correspond to exactly one pixel.
See Also
--------
kwant.plotter.density
""" """
if not _p.mpl_available: if not _p.mpl_available:
...@@ -2035,13 +2044,14 @@ def current(syst, current, relwidth=0.05, **kwargs): ...@@ -2035,13 +2044,14 @@ def current(syst, current, relwidth=0.05, **kwargs):
current density field where the current density is non-zero only on the current density field where the current density is non-zero only on the
straight lines that connect sites that are coupled by a hopping term. straight lines that connect sites that are coupled by a hopping term.
To make this vector field easier to visualize and interpret at different To make this scalar field easier to visualize and interpret at different
length scales, it is smoothed by convoluting it with the bell-shaped bump length scales, it is smoothed by convoluting it with the bell-shaped bump
function ``f(r) = max(1 - (2*r / width)**2, 0)**2``. The bump width is function ``f(r) = max(1 - (2*r / width)**2, 0)**2``. The bump width is
determined by the `relwidth` parameter. determined by the `relwidth` parameter.
This routine samples the smoothed field on a regular (square or cubic) grid This function is similar to `~kwant.plotter.map`, but generally gives more
and displays it using an enhanced variant of matplotlib's streamplot. appealing visual results when used on systems with many sites. If you want
site-level resolution you may be better off using `~kwant.plotter.map`.
Parameters Parameters
---------- ----------
...@@ -2062,6 +2072,9 @@ def current(syst, current, relwidth=0.05, **kwargs): ...@@ -2062,6 +2072,9 @@ def current(syst, current, relwidth=0.05, **kwargs):
fig : matplotlib figure fig : matplotlib figure
A figure with the output if `ax` is not set, else None. A figure with the output if `ax` is not set, else None.
See Also
--------
kwant.plotter.density
""" """
with _common.reraise_warnings(4): with _common.reraise_warnings(4):
return streamplot(*interpolate_current(syst, current, relwidth), return streamplot(*interpolate_current(syst, current, relwidth),
...@@ -2150,6 +2163,11 @@ def density(syst, density, relwidth=0.05, ...@@ -2150,6 +2163,11 @@ def density(syst, density, relwidth=0.05,
------- -------
fig : matplotlib figure fig : matplotlib figure
A figure with the output if `ax` is not set, else None. A figure with the output if `ax` is not set, else None.
See Also
--------
kwant.plotter.current
kwant.plotter.map
""" """
if not _p.mpl_available: if not _p.mpl_available:
raise RuntimeError("matplotlib was not found, but is required " raise RuntimeError("matplotlib was not found, but is required "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment