Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joseph Weston
kwant
Commits
21d32fd3
Commit
21d32fd3
authored
6 years ago
by
Kelvin Loh
Browse files
Options
Downloads
Patches
Plain Diff
2D implementation of the plot() function.
parent
a1daaf85
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwant/_plotter.py
+70
-0
70 additions, 0 deletions
kwant/_plotter.py
kwant/plotter.py
+376
-65
376 additions, 65 deletions
kwant/plotter.py
with
446 additions
and
65 deletions
kwant/_plotter.py
+
70
−
0
View file @
21d32fd3
...
@@ -93,6 +93,76 @@ def nparray_if_array(var):
...
@@ -93,6 +93,76 @@ def nparray_if_array(var):
return
np
.
asarray
(
var
)
if
isarray
(
var
)
else
var
return
np
.
asarray
(
var
)
if
isarray
(
var
)
else
var
if
plotly_available
:
converter_map
=
{
"
o
"
:
0
,
"
v
"
:
6
,
"
^
"
:
5
,
"
<
"
:
7
,
"
>
"
:
8
,
"
s
"
:
1
,
"
+
"
:
3
,
"
x
"
:
4
,
"
*
"
:
17
,
"
d
"
:
2
,
"
h
"
:
14
}
def
convert_symbol_mpl_plotly
(
mpl_symbol
):
if
isarray
(
mpl_symbol
):
converted_symbol
=
[
converter_map
.
get
(
i
)
for
i
in
mpl_symbol
]
else
:
converted_symbol
=
converter_map
.
get
(
mpl_symbol
)
if
converted_symbol
==
None
:
raise
RuntimeWarning
(
'
Input symbol
\'
{}
\'
not supported.
'
'
Only the following are supported: {}
'
.
format
(
mpl_symbol
,
converter_map
.
keys
()))
return
converted_symbol
def
convert_site_size_mpl_plotly
(
mpl_site_size
,
plotly_ref_px
):
return
np
.
sqrt
(
mpl_site_size
)
*
(
96.0
/
72.0
)
*
plotly_ref_px
def
convert_colormap_mpl_plotly
(
mpl_rgba
):
_cmap_plotly
=
255
*
np
.
array
(
mpl_rgba
)
return
'
rgba({},{},{},{})
'
.
format
(
*
_cmap_plotly
[
0
:
-
1
],
_cmap_plotly
[
-
1
]
/
255
)
def
convert_cmap_list_mpl_plotly
(
mpl_cmap_name
,
N
=
255
):
cmap_mpl
=
matplotlib
.
cm
.
get_cmap
(
mpl_cmap_name
)
cmap_mpl_arr
=
matplotlib
.
colors
.
makeMappingArray
(
N
,
cmap_mpl
)
level
=
np
.
linspace
(
1
,
0
,
N
)
cmap_plotly_linear
=
[(
level
,
convert_colormap_mpl_plotly
(
cmap_mpl
))
for
level
,
cmap_mpl
in
zip
(
level
,
cmap_mpl_arr
)]
return
cmap_plotly_linear
def
convert_lead_cmap_mpl_plotly
(
mpl_lead_cmap_init
,
mpl_lead_cmap_end
,
N
=
255
):
r_levels
=
np
.
linspace
(
mpl_lead_cmap_init
[
0
],
mpl_lead_cmap_end
[
0
],
N
)
*
255
g_levels
=
np
.
linspace
(
mpl_lead_cmap_init
[
1
],
mpl_lead_cmap_end
[
1
],
N
)
*
255
b_levels
=
np
.
linspace
(
mpl_lead_cmap_init
[
2
],
mpl_lead_cmap_end
[
2
],
N
)
*
255
a_levels
=
np
.
linspace
(
mpl_lead_cmap_init
[
3
],
mpl_lead_cmap_end
[
3
],
N
)
level
=
np
.
linspace
(
1
,
0
,
N
)
cmap_plotly_linear
=
[(
level
,
'
rgba({},{},{},{})
'
.
format
(
*
rgba
))
for
level
,
rgba
in
zip
(
level
,
zip
(
r_levels
,
g_levels
,
b_levels
,
a_levels
))]
return
cmap_plotly_linear
if
mpl_available
:
if
mpl_available
:
class
LineCollection
(
collections
.
LineCollection
):
class
LineCollection
(
collections
.
LineCollection
):
def
__init__
(
self
,
segments
,
reflen
=
None
,
**
kwargs
):
def
__init__
(
self
,
segments
,
reflen
=
None
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
kwant/plotter.py
+
376
−
65
View file @
21d32fd3
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment