-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Added a matrix plot #668
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #668 +/- ##
==========================================
- Coverage 85.77% 85.74% -0.03%
==========================================
Files 367 372 +5
Lines 43917 44277 +360
==========================================
+ Hits 37669 37967 +298
- Misses 6248 6310 +62 ☔ View full report in Codecov by Sentry. |
Looks very cool! Some ideas
|
It doesn't show any text or colors in the empty entries. Also, the matrix is not folded, all supercells are shown. See this graphene Hamiltonian: import sisl
g = sisl.geom.graphene()
H = sisl.Hamiltonian(g)
r = (0.1, 1.44)
t = (0.2, -2.7)
H.construct([r, t])
H.plot(text=".2f", sc_lines=True) But
Good idea, I will add the possibility of plotting one arrow on each matrix element. Regarding the comments of multiplying by the overlap (e.g. mulliken), the result of those is not a matrix, no? It would be a different visualization, right? |
arrow["data"] = matrix_as_array(arrow["data"], dim=None) | ||
|
||
if "center" not in arrow: | ||
arrow["center"] = "middle" |
Check failure
Code scanning / CodeQL
Modification of parameter with default Error
default value
This expression mutates a
default value
I included the possibility to add arrows. The interface is the same as the one to include arrows in the geometry plot. The arrows are normalized so that all of them fit inside the element's box. import sisl
import numpy as np
g = sisl.geom.graphene()
H = sisl.Hamiltonian(g, dim=2)
r = (0.1, 1.44)
t = (1.9, -2.7)
H.construct([r, t])
# Second dimension is just random
H._csr.data[:, 1] = H._csr.data[:, 0] * (np.random.random(len(H._csr.data)) * 2 - 1)
plot = H.plot(text=".2f", sc_lines=True, dim=0)
# Without arrows
plot.show()
# With arrows
plot.update_inputs(arrows=[
{"data": H, "center": "middle", "color": "lightgreen", "opacity": 0.7, "name": "Something"}
]) Does this make sense? Also I was wondering that data with multiple dimensions could also be displayed with multiple color channels. E.g. RGB. I don't know if that would be helpful in some case. |
Great, looks good!
The It is actually more of an energy resolved quantity, think LDOS |
For
Again, I think this depends on the matrix data. For instance, for orbital/bond-current matrices, it could be cool to somehow show the off-diagonal arrows as pointing the current towards the other atom, if current is flowing in that direction. |
The implementation of the arrows just plots the first two components of the sparse matrix that you pass to So the user would have to pass arrows that make sense. If you know about something that would make sense to plot as arrows we can provide functions for it. |
I think for DM, it would make sense to extract the x,y,z components, then project onto a user-defined plane, and then plot that arrow, of course scaled with the spin-magnitude. When the DM is only polarized, I think it only makes sense to plot up/down arrows according to the spin-magnitude. For the COOP ( Same for bond-currents... For H, I don't know, yet ;) |
Here some comments which I think we could use to finalize this:
Then I think we can ship it in |
Ok, I added the changes you proposed and now I'm writing the tutorial notebook and some tests |
Could you have a look at the notebook to see if everything works as you would expect? The one in I have to write some tests and then the PR will be ready |
Looks really nice! Let me know when the tests are ready, it can then be merged. :) |
Ok, done! |
This plot is something that I commonly use and I figured it would be a good addition for the visualization module.
To test it one can do:
which is just a simple image, but from there you can ask for many extra features like separators or text, which is specially nice for small matrices and can be useful to debug problems in sisl or SIESTA for example.
Let me know if there is some feature that you think could be useful to add, or if there is some default you would change, etc... and then I'll finish the PR with tests and a demo notebook.
@tfrederiksen also if you have something to say I would be happy to hear your thoughts on it :)
And @juijan if you have some idea for something more complex to visualize spin matrices also it would be nice to hear, right know all I can think of is just plotting each component separately.
Cheers!