...
|
...
|
@@ -1429,27 +1429,37 @@ def bands(sys, args=(), momenta=65, file=None, show=True, dpi=None,
|
1429
|
1429
|
Either a number of sampling points on the interval [-pi, pi], or an
|
1430
|
1430
|
array of points at which the band structure has to be evaluated.
|
1431
|
1431
|
file : string or file object or `None`
|
1432
|
|
- The output file. If `None`, output will be shown instead.
|
|
1432
|
+ The output file. If `None`, output will be shown instead. If plotly is
|
|
1433
|
+ selected as the backend, the filename has to end with a html extension.
|
1433
|
1434
|
show : bool
|
1434
|
|
- Whether ``matplotlib.pyplot.show()`` is to be called, and the output is
|
1435
|
|
- to be shown immediately. Defaults to `True`.
|
|
1435
|
+ For matplotlib backend, whether ``matplotlib.pyplot.show()`` is to be
|
|
1436
|
+ called, and the output is to be shown immediately.
|
|
1437
|
+ For the plotly backend, a call to ``iplot(fig)`` is made if
|
|
1438
|
+ show is True.
|
|
1439
|
+ Defaults to `True` for both backends.
|
1436
|
1440
|
dpi : float
|
1437
|
1441
|
Number of pixels per inch. If not set the ``matplotlib`` default is
|
1438
|
1442
|
used.
|
|
1443
|
+ Only for matplotlib backend. If the plotly backend is selected and
|
|
1444
|
+ this argument is not None, then a RuntimeError will be triggered.
|
1439
|
1445
|
fig_size : tuple
|
1440
|
1446
|
Figure size `(width, height)` in inches. If not set, the default
|
1441
|
1447
|
``matplotlib`` value is used.
|
|
1448
|
+ Only for matplotlib backend. If the plotly backend is selected and
|
|
1449
|
+ this argument is not None, then a RuntimeError will be triggered.
|
1442
|
1450
|
ax : ``matplotlib.axes.Axes`` instance or `None`
|
1443
|
1451
|
If `ax` is not `None`, no new figure is created, but the plot is done
|
1444
|
1452
|
within the existing Axes `ax`. in this case, `file`, `show`, `dpi`
|
1445
|
1453
|
and `fig_size` are ignored.
|
|
1454
|
+ Only for matplotlib backend. If the plotly backend is selected and
|
|
1455
|
+ this argument is not None, then a RuntimeError will be triggered.
|
1446
|
1456
|
params : dict, optional
|
1447
|
1457
|
Dictionary of parameter names and their values. Mutually exclusive
|
1448
|
1458
|
with 'args'.
|
1449
|
1459
|
|
1450
|
1460
|
Returns
|
1451
|
1461
|
-------
|
1452
|
|
- fig : matplotlib figure
|
|
1462
|
+ fig : matplotlib figure or plotly Figure object
|
1453
|
1463
|
A figure with the output if `ax` is not set, else None.
|
1454
|
1464
|
|
1455
|
1465
|
Notes
|
...
|
...
|
@@ -1457,11 +1467,20 @@ def bands(sys, args=(), momenta=65, file=None, show=True, dpi=None,
|
1457
|
1467
|
See `~kwant.physics.Bands` for the calculation of dispersion without plotting.
|
1458
|
1468
|
"""
|
1459
|
1469
|
|
1460
|
|
- if not _p.mpl_available:
|
|
1470
|
+ if not _p.mpl_available and (get_backend() == _p.Backends.matplotlib):
|
1461
|
1471
|
raise RuntimeError("matplotlib was not found, but is required "
|
1462
|
|
- "for bands()")
|
|
1472
|
+ "for bands() by the selected backend")
|
|
1473
|
+
|
|
1474
|
+ if not _p.plotly_available and (get_backend() == _p.Backends.plotly):
|
|
1475
|
+ raise RuntimeError("plotly was not found, but is required "
|
|
1476
|
+ "for bands() by the selected backend")
|
1463
|
1477
|
|
1464
|
1478
|
syst = sys # for naming consistency inside function bodies
|
|
1479
|
+
|
|
1480
|
+ if get_backend() == _p.Backends.plotly:
|
|
1481
|
+ _check_incompatible_args_plotly(dpi, fig_size, ax)
|
|
1482
|
+
|
|
1483
|
+
|
1465
|
1484
|
_common.ensure_isinstance(syst, (system.InfiniteSystem, system.InfiniteVectorizedSystem))
|
1466
|
1485
|
|
1467
|
1486
|
momenta = np.array(momenta)
|