0todd0000 / spm1d

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

Issue plotting multiple inference plots #98

Closed st472 closed 5 years ago

st472 commented 5 years ago

Hi,

I am running multiple repeated measures anovas as i have a number of different muscles that I have to analyse. I have created a while loop (code below) that will compute the spm and spm inference data for each muscle plus generate a inference plot. However, instead of separate plots i getting one plot with all of the inference lines plotted.

Is there away to get spm1d to plot a new graph each time?

Regards Sam

i = 1

while i < 21: F = spm1d.stats.anova1rm(Y[M==i], C[M==i], P[M==i]) FIn = F.inference(alpha=0.05) FIn.plot() print(F) print(FIn.clusters) i += 1

m-a-robinson commented 5 years ago

Hello, You should be able to do this by defining the figure number first plt.figure(i). The example below is taken from the ex_anova1rm.py script so the analysis will produce the same result in each figure. Regards Mark

import numpy as np
from matplotlib import pyplot as plt
import spm1d

#(0) Load dataset:
dataset      = spm1d.data.uv1d.anova1rm.SpeedGRFcategoricalRM()
Y,A,SUBJ     = dataset.get_data()

#(1) Run ANOVA
alpha        = 0.05
equal_var    = True

i = 1
while i < 5:
    Frm          = spm1d.stats.anova1rm(Y, A, SUBJ, equal_var) 
    Firm         = Frm.inference(alpha)
    plt.figure(i)
    Firm.plot()
    i += 1
st472 commented 5 years ago

Thanks, Mark, This works perfectly. Regards Sam