BMClab / BMC

Notes on Scientific Computing for Biomechanics and Motor Control
https://bmclab.github.io/BMC/
Creative Commons Attribution 4.0 International
435 stars 265 forks source link

Issue when specifying ax object for plotting #5

Closed avdbspecific closed 5 years ago

avdbspecific commented 6 years ago

Thanks for this code, it's been useful so far !

I discovered a small issue in the _plot() method. When specifying an ax object only the first reference would be plot.

The issue can be replicated as: fig, ax = plt.subplots(ncols=3,nrows=3,figsize=(16,12)) ind1 = detectPeaks.detectPeaks(a1, show=True, ax=ax[2,0], threshold=0, kpsh=True, mpd=2, mph=5e-2) ind2 = detectPeaks.detectPeaks(a2, show=True, ax=ax[2,1], threshold=0, kpsh=True, mpd=2, mph=5e-2)

The workaround is easy: if ax is None: _, ax = plt.subplots(1, 1, figsize=(8, 4)) noAx = True else: noAx = False (...)

if noAx: plt.show()

demotu commented 5 years ago

corrected. thank you.