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

Complaints about the spin arrows #73

Closed
MRedies opened this issue Sep 2, 2021 · 1 comment
Closed

Complaints about the spin arrows #73

MRedies opened this issue Sep 2, 2021 · 1 comment

Comments

@MRedies
Copy link
Contributor

MRedies commented Sep 2, 2021

I am trying to use plot as spin-polarized dos and I have two complaints about the little arrows that indicate which is up and which is down. First, the arrows don't scale with the plot size, so can be too large in small plots or vice versa:

grafik

My main complaint is however, that the show_arrows=False option doesn't work:

f, ax = plt.subplots(1,1, figsize=np.array([6,4])*1.2, constrained_layout=True)

with HDF5Reader("../../calc/YIG/PBE/kpts=0003/DOS/banddos.hdf") as h5reader:
    data, attributes = h5reader.read(recipe=FleurDOS)

    plot_fleur_dos(data, attributes, multiply_by_equiv_atoms=True, linewidth=1.5, axis=ax,
                   show=False, title="PBE", legend_options={'fontsize':12}, 
                   limits={'energy':[-8.5,8.5]}, legend=False, spin_arrows=False)
plt.savefig("PBE.pdf")
plt.show()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_24650/841951966.py in <module>
      4     data, attributes = h5reader.read(recipe=FleurDOS)
      5 
----> 6     plot_fleur_dos(data, attributes, multiply_by_equiv_atoms=True, linewidth=1.5, axis=ax,
      7                    show=False, title="PBE", legend_options={'fontsize':12},
      8                    limits={'energy':[-8.5,8.5]}, legend=False, spin_arrows=False)

~/.local/lib/python3.8/site-packages/masci_tools/vis/fleur.py in plot_fleur_dos(dosdata, attributes, spinpol, bokeh_plot, multiply_by_equiv_atoms, plot_keys, show_total, show_interstitial, show_sym, show_atoms, show_lresolved, key_mask, **kwargs)
    381             dosdata_up = [dosdata[key].to_numpy() for key in keys if '_up' in key]
    382             dosdata_dn = [dosdata[key].to_numpy() for key in keys if '_down' in key]
--> 383             fig = plot_spinpol_dos(dosdata['energy_grid'], dosdata_up, dosdata_dn, plot_label=legend_labels, **kwargs)
    384         else:
    385             dosdata_up = [dosdata[key].to_numpy() for key in keys if '_up' in key]

~/.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_dos(energy_grid, spin_up_data, spin_dn_data, saveas, energy_label, dos_label, title, xyswitch, energy_grid_dn, e_fermi, spin_dn_negative, **kwargs)
   1767 
   1768     with NestedPlotParameters(plot_params):
-> 1769         ax = multiple_scatterplots(x,
   1770                                    y,
   1771                                    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 multiple_scatterplots(xdata, ydata, xlabel, ylabel, title, saveas, axis, xerr, yerr, area_curve, **kwargs)
    353                             **kwargs)
    354         else:
--> 355             result = ax.errorbar(x, y, yerr=yerrt, xerr=xerrt, **plot_kw, **kwargs)
    356             colors.append(result.lines[0].get_color())
    357 

~/.local/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)

~/.local/lib/python3.8/site-packages/matplotlib/axes/_axes.py in errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs)
   3339         # that would call self._process_unit_info again, and do other indirect
   3340         # data processing.
-> 3341         (data_line, base_style), = self._get_lines._plot_args(
   3342             (x, y) if fmt == '' else (x, y, fmt), kwargs, return_kwargs=True)
   3343 

~/.local/lib/python3.8/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs, return_kwargs)
    535 
    536         if return_kwargs:
--> 537             return list(result)
    538         else:
    539             return [l[0] for l in result]

~/.local/lib/python3.8/site-packages/matplotlib/axes/_base.py in <genexpr>(.0)
    530             labels = [label] * n_datasets
    531 
--> 532         result = (make_artist(x[:, j % ncx], y[:, j % ncy], kw,
    533                               {**kwargs, 'label': label})
    534                   for j, label in enumerate(labels))

~/.local/lib/python3.8/site-packages/matplotlib/axes/_base.py in _makeline(self, x, y, kw, kwargs)
    352         default_dict = self._getdefaults(set(), kw)
    353         self._setdefaults(default_dict, kw)
--> 354         seg = mlines.Line2D(x, y, **kw)
    355         return seg, kw
    356 

~/.local/lib/python3.8/site-packages/matplotlib/lines.py in __init__(self, xdata, ydata, linewidth, linestyle, color, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)
    395         # update kwargs before updating data to give the caller a
    396         # chance to init axes (and hence unit support)
--> 397         self.update(kwargs)
    398         self.pickradius = pickradius
    399         self.ind_offset = 0

~/.local/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: 'Line2D' object has no property 'spin_arrows'

Somehow it doesn't get caugt and just drops down to the lowest level.

@MRedies
Copy link
Contributor Author

MRedies commented Sep 2, 2021

Ok in the developmen branch it works! Thank you

@MRedies MRedies closed this as completed Sep 2, 2021
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

1 participant