Search code examples
matlabmultidimensional-arrayribbonwaterfalllinestyle

Waterfall or Ribbon plot of stacked data (XRD) with color constant lines and spacing determined by another variable


I'm struggling to make a plot that I find useful with my current set of X-ray diffraction data. I have multiple x-ray scans that I'd like to place in a 3d arrangement according to a third variable. [i.e., compare the theta-two-theta (x,y) measured data to a variable in my control-space]

What I'm looking for is either like a waterfall plot or a ribbon plot, but both appear to be limiting. For the waterfall plot, it appears spacing is determined not by a variable, but by the function, similarly to a ribbon-plot, which takes x,y data only, and uses equal spacing and colors along the colormap.

This is similar to stacking XRD plots, but I figured it would be nice to have the spacing between each plot be directly linked to a testing variable in our lab.

Color I'd like to be constant for each line, determined by the nice color routine linspecer.

Are there any plots that control the third dimension by a variable for spacing of the lines? I have each line separate in a data struct right now, but can massage the data to be what is needed for suggested solutions.


Solution

  • If you want control of each individual line, the 3-D line plot plot3() might be what you are looking for.

    This short example makes use of the peaks data but changes the spacing between the lines.

    [x,y] = meshgrid(-3:.5:3,-3:.1:3);
    z = peaks(x,y);
    
    % Change spacing of x
    xNew = sign(x).*sqrt(abs(x));
    
    plot3(x,y,z,'b')
    figure
    plot3(xNew,y,z,'b')
    

    This produces the following two figures. The first one shows the original spacing and the second one uses the modified spacing.

    Plot with the original spacing

    Plot with the modified spacing

    If you want individual colors of each line you can loop through them and set them individually as in this answer at matlab central.