Skip to content

Commit ffc3e57

Browse files
committed
PowderPattern: avoid NaN warning for arcsin calculation. Use matplotlib's axes text.clear() (setting to [] is not possible with matplotlib>=3.5)
1 parent 310e553 commit ffc3e57

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/pyobjcryst/powderpattern.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def plot(self, diff=None, hkl=None, figsize=(9, 4), fontsize_hkl=6, reset=False,
121121
plt.figure(figsize=figsize)
122122
plt.plot(x, obs, 'k', label='obs', linewidth=1)
123123
plt.plot(x, calc, 'r', label='calc', linewidth=1)
124-
m = self.GetMaxSinThetaOvLambda() * self.GetWavelength()
124+
m = min(1, self.GetMaxSinThetaOvLambda() * self.GetWavelength())
125125
mtth = np.rad2deg(np.arcsin(m)) * 2
126126
if plot_diff:
127127
diff = calc - obs - obs.max() / 20
@@ -191,8 +191,7 @@ def _do_plot_hkl(self, nb_max=100, fontsize_hkl=None):
191191
calc = self.GetPowderPatternCalc()
192192
x = np.rad2deg(self.GetPowderPatternX())
193193
# Clear previous text (assumes only hkl were printed)
194-
plt.gca().texts = []
195-
iphase = 0
194+
plt.gca().texts.clear()
196195
for ic in range(self.GetNbPowderPatternComponent()):
197196
c = self.GetPowderPatternComponent(ic)
198197
if isinstance(c, PowderPatternDiffraction) is False:

0 commit comments

Comments
 (0)