0todd0000 / spm1dmatlab

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

Fill the gap between curve and line #196

Closed CoraBora closed 7 months ago

CoraBora commented 10 months ago

I am trying to generate a similar plot with my own features. How can I color the significant areas? I only manage to color the entire area between the curve and the threshold. I have tried many different options but unfortunately I can't find the solution. I have already asked in the general Matlab forum but I didn't get any further there either.

This is my code:

curve = F(:,2)'; line = 13; plot(curve,'k'); hold on; area(x,curve,line,'FaceColor','c','LineWidth',1); yline(line, '--r',LineWidth=2)

untitled

This is how it should look (only the shaded areas): image

m-a-robinson commented 10 months ago

I am not sure that Matlab has a build in function for this (unlike Python -> Matplotlib). A quick search found this on the Matlab file exchange https://uk.mathworks.com/matlabcentral/fileexchange/47151-fill_between which would seem to do what you want. You can of course customise the existing plot should you wish rather than having to create a new plot from scratch. Regards Mark