Skip to content
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

Line plot for bands doesn't work #72

Closed
MRedies opened this issue Aug 20, 2021 · 10 comments
Closed

Line plot for bands doesn't work #72

MRedies opened this issue Aug 20, 2021 · 10 comments

Comments

@MRedies
Copy link
Contributor

MRedies commented Aug 20, 2021

I am trying to plot a bandstructure with lines instead of dots. I tried to use the option line_plot=True documented here:

https://masci-tools.readthedocs.io/en/latest/module_guide/code.html?highlight=plot_bands#masci_tools.vis.plot_methods.plot_bands

I did it in this jupyter notebook, but I'll try to copy it a swell
line_plot.zip

from masci_tools.io.parsers.hdf5 import HDF5Reader
from masci_tools.io.parsers.hdf5.recipes import FleurBands
from masci_tools.vis.fleur import plot_fleur_bands

#Read in data
with HDF5Reader('banddos.hdf') as h5reader:
   data, attributes = h5reader.read(recipe=FleurBands)



#Plot the data
#Notice that you get the axis object of this plot is returned
#if you want to make any special additions
ax = plot_fleur_bands(data, attributes, limits={'y': (-3,5)}, line_plot=True)

results in

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-25-afd0580a8c3a> in <module>
     12 #Notice that you get the axis object of this plot is returned
     13 #if you want to make any special additions
---> 14 ax = plot_fleur_bands(data, attributes, limits={'y': (-3,5)}, line_plot=True)

~/.local/lib/python3.8/site-packages/masci_tools/vis/fleur.py in plot_fleur_bands(bandsdata, bandsattributes, spinpol, only_spin, bokeh_plot, weight, **kwargs)
    276     else:
    277         if spinpol:
--> 278             fig = plot_spinpol_bands(bandsdata['kpath'],
    279                                      bandsdata['eigenvalues_up'],
    280                                      bandsdata['eigenvalues_down'],

~/.local/lib/python3.8/site-packages/masci_tools/vis/parameters.py in ensure_consistency(*args, **kwargs)
     77 
     78             try:
---> 79                 res = func(*args, **kwargs)
     80             except Exception:
     81                 plotter_object.remove_added_parameters()

~/.local/lib/python3.8/site-packages/masci_tools/vis/plot_methods.py in plot_spinpol_bands(kpath, bands_up, bands_dn, size_data, show_spin_pol, special_kpoints, e_fermi, xlabel, ylabel, title, saveas, markersize_min, markersize_scaling, scale_color, **kwargs)
   1965         plot_params.set_defaults(default_type='function', sub_colormap=(0.15, 1.0))
   1966 
-> 1967     ax = multi_scatter_plot([kpath, kpath], [bands_up, bands_dn],
   1968                             size_data=size_data,
   1969                             xlabel=xlabel,

~/.local/lib/python3.8/site-packages/masci_tools/vis/parameters.py in ensure_consistency(*args, **kwargs)
     77 
     78             try:
---> 79                 res = func(*args, **kwargs)
     80             except Exception:
     81                 plotter_object.remove_added_parameters()

~/.local/lib/python3.8/site-packages/masci_tools/vis/plot_methods.py in multi_scatter_plot(xdata, ydata, size_data, color_data, xlabel, ylabel, title, saveas, axis, **kwargs)
    476             plot_kw.pop('color')
    477 
--> 478         res = ax.scatter(x, y=y, s=size, c=color, **plot_kw, **kwargs)
    479         if plot_kw.get('label', None) is not None and color is not None:
    480             if isinstance(color, (list, np.ndarray, pd.Series)):

/usr/local/anaconda3/lib/python3.8/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1359     def inner(ax, *args, data=None, **kwargs):
   1360         if data is None:
-> 1361             return func(ax, *map(sanitize_sequence, args), **kwargs)
   1362 
   1363         bound = new_sig.bind(ax, *args, **kwargs)

/usr/local/anaconda3/lib/python3.8/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, edgecolors, plotnonfinite, **kwargs)
   4595                 )
   4596         collection.set_transform(mtransforms.IdentityTransform())
-> 4597         collection.update(kwargs)
   4598 
   4599         if colors is None:

/usr/local/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py in update(self, props)
   1060                     func = getattr(self, f"set_{k}", None)
   1061                     if not callable(func):
-> 1062                         raise AttributeError(f"{type(self).__name__!r} object "
   1063                                              f"has no property {k!r}")
   1064                     ret.append(func(v))

AttributeError: 'PathCollection' object has no property 'line_plot'
@janssenhenning
Copy link
Contributor

janssenhenning commented Aug 20, 2021

Oh that's unfortunate. The default documentation in readthedocs points to the docs of the develop branch. We should probably change that.
You had unlucky timing, since I only merged this feature today :D
If you wanna use it now you'll have to use the newest develop branch

@MRedies
Copy link
Contributor Author

MRedies commented Aug 20, 2021

I did a python3 -m pip install --upgrade masci-tools, but this doesn't seem to get me to the development version.

Can I get the development version through pip?

@janssenhenning
Copy link
Contributor

No there's no pre-release for this feature yet, which you could install through pip.

You'll have to clone the git repository, checkout the develop branch and install it with calling pip install -e . in the repository

@MRedies
Copy link
Contributor Author

MRedies commented Aug 20, 2021

Are you sure this feature works correctly? I pulled newest version from github, where the tests pass:

Requirement already satisfied: zipp>=0.5 in /Users/alzeer/.local/lib/python3.6/site-packages (from importlib-metadata; python_version < "3.8"->SQLAlchemy<2.0.0,>=1.3.23->mendeleev->masci-tools==0.5.0)
Installing collected packages: masci-tools
  Found existing installation: masci-tools 0.4.8
    Uninstalling masci-tools-0.4.8:
      Successfully uninstalled masci-tools-0.4.8
  Running setup.py develop for masci-tools
Successfully installed masci-tools
bash-4.4$ pip3 show masci-tools
Name: masci-tools
Version: 0.5.0
Summary: Tools for Materials science. Vis contains wrappers of matplotlib functionality to visualize common material science data. Plus wrappers of visualisation for aiida-fleur workflow nodes
Home-page: https://github.com/JuDFTteam/masci-tools
Author: Jens Broeder
Author-email: [email protected]
License: MIT License, see LICENSE.txt file.
Location: /Users/alzeer/masci-tools
Requires: numpy, scipy, matplotlib, h5py, pandas, ase, bump2version, future, lxml, more-itertools, seaborn, deepdiff, humanfriendly, mendeleev
bash-4.4$ git rev-parse HEAD
84354df6022cd11519cfd5efca417eb87ccff3c3

and I still get the initial error.

@janssenhenning
Copy link
Contributor

Yes, there is a test which is literally the code block you have 🤔
Did you restart the jupyter notebook after installing the develop version?

@MRedies
Copy link
Contributor Author

MRedies commented Aug 20, 2021

I restarted the Kernel, which usually works for changes in my modules

@janssenhenning
Copy link
Contributor

janssenhenning commented Aug 20, 2021

And the kernel corresponds to the correct python executable, where you installed the develop version?
Can you do the following without error import masci_tools.vis.data?

@MRedies
Copy link
Contributor Author

MRedies commented Aug 20, 2021

No. This module seems unknown. I had to try a bit a few combinations untill I found a pip, that would let me install things without superuser.

@MRedies
Copy link
Contributor Author

MRedies commented Aug 20, 2021

I don't know how jupyter selects their python kernel. Maybe you can help Mahmood next time when you are in Jülich.

@janssenhenning
Copy link
Contributor

Yes I'll be happy to help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants