0todd0000 / spm1d

One-Dimensional Statistical Parametric Mapping in Python
GNU General Public License v3.0
60 stars 21 forks source link

Shading significance along signal traces #285

Closed Andres-Jaramillo closed 1 month ago

Andres-Jaramillo commented 2 months ago

Dear spm1d and Todd Sorry in advance for the simple question. Is there a method already implemented in the "plot class" for plotting/shading the significant regions (along x axis) in the plot on top of the signal traces, as in the plots I attach here? I was trying to find such in the documentation, code, and here in the forum. Kind regards to all. Andres

Screenshot 2024-04-28 210617

0todd0000 commented 2 months ago

Hello Andres, This is not directly supported in the current version of spm1d but can be achieved using Matplotlib's axvspan. You can use cluster.endpoints to get the relevant x-axis positions, for example:

spmi  = spm1d.stats.ttest2(y1, y0).inference(0.05)
x0,x1 = spmi.clusters[0].endpoints
plt.axvspan(x0, x1, color='red', alpha=0.5)
Andres-Jaramillo commented 2 months ago

Dear Todd, That just worked perfectly! Thanks