0todd0000 / spm1dmatlab

One-Dimensional Statistical Parametric Mapping in Matlab.
GNU General Public License v3.0
28 stars 13 forks source link

change fontsize of p-value labels #161

Closed MarkKramer closed 2 years ago

MarkKramer commented 2 years ago

Dear colleagues,

I just wanted to know if it is possible to automatically change the fontsize of the p-value labels? Presently the plotting code is:

    spmi.plot();
    spmi.plot_threshold_label();
    spmi.plot_p_values();
    title('Hypothesis Test');

I tried spmi.plot_p_values('FontSize', 8), but this does not work. Is there perhaps another way to do this?

Kind regards,

Mark

0todd0000 commented 2 years ago

It is possible, but this would need to be done manually; spm1d currently supports only basic plotting options. The relevant code is in ./spm1dmatlab/+spm1d/+plot/Plotter.m, and below is a slightly simplified version of the plot_p_values function. By modifying the set command you should be able to change the font size.

function [hh] = plot_p_values(spmi)
    offset = 0;
    hh     = zeros(1, spmi.nClusters);
    for i = 1:spmi.nClusters
        cluster = spmi.clusters{i};
        if cluster.iswrapped
            h  = self.plot_p_value_wrapped(cluster, offset);
        else
            xy = cluster.xy;
            h  = text(xy(1)+offset(1), xy(2)+offset(2), self.p2str(cluster.P));
        end
        hh(i)  = h;
    end
    set(hh, 'HorizontalAlignment','center', 'BackgroundColor', 0.95*[1 1 1])
    hh = num2cell(hh);
end
MarkKramer commented 2 years ago

Perfect. THank you Prof Pataky.