mirror of https://github.com/phonopy/phono3py.git
Update kdeplot
This commit is contained in:
parent
563806b9af
commit
42251d5eb4
|
@ -230,8 +230,8 @@ After finishing the calculation, the plot is saved in
|
|||
``lifetime.png``. The black dots show original data points. The
|
||||
drawing area is automatically set to make the look good, where its
|
||||
higher lifetime side is not drawn if all density beyond a lifetime
|
||||
value is smaller than some percentage (default: 10%) of the maximum
|
||||
density.
|
||||
value is smaller than some ratio (see
|
||||
:ref:`kdeplot_density_ratio`) of the maximum density.
|
||||
|
||||
The following plot is drawn with a
|
||||
19x19x19 mesh and nbins=200 and the ``Si-PBEsol`` example is used to
|
||||
|
@ -304,17 +304,20 @@ https://matplotlib.org/users/colormaps.html.
|
|||
|
||||
% kdeplot --cmap="OrRd" kappa-m111111.hdf5
|
||||
|
||||
``--min_density``
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
.. _kdeplot_density_ratio:
|
||||
|
||||
``--dr``, ``--density_ratio``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**New** (``kdeplot`` is a stand-alone script. The latest version is
|
||||
download at
|
||||
https://github.com/atztogo/phono3py/blob/develop/scripts/kdeplot.)
|
||||
|
||||
The density threshold is specified by the ratio with respect to
|
||||
maximum density. The default value is 0.1. When ``--ymax`` is
|
||||
specified together, this option is ignored.
|
||||
maximum density. Normally smaller value results in larger drawing
|
||||
region. The default value is 0.1. When ``--ymax`` is specified
|
||||
together, this option is ignored.
|
||||
|
||||
::
|
||||
|
||||
% kdeplot --min_density=0.01 kappa-m111111.hdf5
|
||||
% kdeplot --dr=0.01 kappa-m111111.hdf5
|
||||
|
|
|
@ -35,7 +35,7 @@ def collect_data(gamma, weights, frequencies, t_index, cutoff, max_freq):
|
|||
|
||||
return x, y
|
||||
|
||||
def run_KDE(x, y, nbins, y_max=None, min_density=0.1):
|
||||
def run_KDE(x, y, nbins, y_max=None, density_ratio=0.1):
|
||||
"""Running Gaussian-KDE by scipy
|
||||
"""
|
||||
|
||||
|
@ -59,7 +59,7 @@ def run_KDE(x, y, nbins, y_max=None, min_density=0.1):
|
|||
for i, r_zi in enumerate((zi.T)[::-1]):
|
||||
if indices:
|
||||
indices.append(nbins - i - 1)
|
||||
elif np.max(r_zi) > zi_max * min_density:
|
||||
elif np.max(r_zi) > zi_max * density_ratio:
|
||||
indices = [nbins - i - 1]
|
||||
short_nbinds = len(indices)
|
||||
|
||||
|
@ -115,12 +115,12 @@ parser.add_argument("--cutoff",
|
|||
help=("Property (y-axis) below this value is included in "
|
||||
"data before running Gaussian-KDE"),
|
||||
type=float, default=None)
|
||||
parser.add_argument("--fmax", help="Max frequency to plot",
|
||||
type=float, default=None)
|
||||
parser.add_argument("--min_density",
|
||||
parser.add_argument("--dr", "--density_ratio", dest="density_ratio",
|
||||
help=("Minimum density ratio with respect to maximum "
|
||||
"density used to determine drawing region"),
|
||||
type=float, default=0.1)
|
||||
parser.add_argument("--fmax", help="Max frequency to plot",
|
||||
type=float, default=None)
|
||||
parser.add_argument('--nbins', type=int, default=100,
|
||||
help=("Number of bins in which data are assigned, "
|
||||
"i.e., determining resolution of plot")),
|
||||
|
@ -201,7 +201,7 @@ for gamma, s in zip(gammas, symbols):
|
|||
t_index, args.cutoff, args.fmax)
|
||||
xi, yi, zi, short_nbinds = run_KDE(x, y, args.nbins,
|
||||
y_max=args.ymax,
|
||||
min_density=args.min_density)
|
||||
density_ratio=args.density_ratio)
|
||||
fig = plot(plt, xi, yi, zi, x, y, short_nbinds, args.nbins,
|
||||
y_max=args.ymax, cmap=args.cmap)
|
||||
if s:
|
||||
|
|
Loading…
Reference in New Issue