Skip to content

Commit 235db34

Browse files
committed
get() can return original argument as part of tuple
Fixed bug in plotting 3D class prob highlights, and color them using a colormap.
1 parent d9851e9 commit 235db34

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

diffpy/srmise/multimodelselection.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ def plot3dclassprobs(self, **kwds):
464464
If equal to "auto" determined by the number of models in displayed classes.
465465
cmap - A colormap or registered colormap name. Default is cm.jet. If class_size is "number" and norm is either "auto"
466466
or "full" the map is converted to an indexed colormap.
467+
highlight_cmap - A colormap or registered colormap name for coloring highlights. Default is cm.gray.
467468
title - True, False, or a string. Defaults to True, which displays some basic information about the graph.
468469
p_alpha - Probability graph alpha. (Colorbar remains opaque). Default is 0.7.
469470
figure - A matplotlib.figure.Figure instance. Default is the current figure.
@@ -498,6 +499,7 @@ def plot3dclassprobs(self, **kwds):
498499
class_size = kwds.pop("class_size", "number")
499500
norm = kwds.pop("norm", "auto")
500501
cmap = kwds.pop("cmap", cm.jet)
502+
highlight_cmap = kwds.pop("highlight_cmap", cm.gray)
501503
title = kwds.pop("title", True)
502504
p_alpha = kwds.pop("p_alpha", 0.7)
503505
scale = kwds.pop("scale", 1.)
@@ -554,10 +556,10 @@ def plot3dclassprobs(self, **kwds):
554556
cax = ax.add_collection3d(poly, zs=zs, zdir='y')
555557

556558
# Highlight values of interest
557-
for dG in highlight:
558-
#ax.plot([dG, dG], [zs[0], zs[-1]], [0, 0], color='k')
559-
for i, z in enumerate(zs):
560-
ax.plot([dG, dG], [z, z], [0, self.classprobs[dG][i]], color='k', alpha=p_alpha)
559+
color_idx = np.linspace(0, 1, len(highlight))
560+
for dG, ci in zip(highlight, color_idx):
561+
for z_logical, z_plot in zip(zlabels, zs):
562+
ax.plot([dG, dG], [z_plot, z_plot], [0, self.classprobs[dG][z_logical]], color=highlight_cmap(ci), alpha=p_alpha)
561563

562564
ax.set_xlabel('dG')
563565
ax.set_xlim3d(dGs[0]*scale, dGs[-1]*scale)
@@ -703,8 +705,8 @@ def get(self, dG, *args, **kwds):
703705
Parameters:
704706
dG - The uncertainty used to calculate probabilities
705707
706-
Permissible arguments: "aic", "class", "model", "nfree", "prob"
707-
708+
Permissible arguments: "aic", "class", "dG", "model", "nfree", "prob"
709+
("dG" simply returns the provided dG value)
708710
709711
Keywords:
710712
corder - Which class to get based on AIC. Ordered from best to worst from 0 (the default).
@@ -713,6 +715,7 @@ def get(self, dG, *args, **kwds):
713715
cls - Override corder with a specific class index, or None to ignore classes entirely."""
714716
fdict = {"aic": self.get_aic,
715717
"class": self.get_class,
718+
"dg": lambda x: x,
716719
"model": self.get_model,
717720
"nfree": self.get_nfree,
718721
"prob": self.get_prob}

0 commit comments

Comments
 (0)