Area plot style graph

1 view (last 30 days)
Andy
Andy on 21 Feb 2013
I am trying to recreate a graph. There is 3 layers and i want the values of each layer to oscillate between particular values. I have the correct values stored in bl, gr and ye but when plotted onto the area graph they add to each other so end up oscillating around different values. I know this is because area plots sum up the values beneath it, but is there a way to recreate a similar looking graph but with the oscillation around the actual values i have calculated.
Also although i have 50 values i want the x axis on the graph to only go from 0-1, so any help with that is also appreciated.
This is what i have so far.
clc
clear all
close all
bl = 2.5 + (3.5-2.5).*rand(50,1);
gr = 1.5 + (2.5-1.5).*rand(50,1);
ye = 0.5 + (1.5-0.5).*rand(50,1);
y = [bl gr ye];
area(y)
colormap summer

Answers (2)

Thorsten
Thorsten on 21 Feb 2013
Edited: Thorsten on 21 Feb 2013
area([y(:, 1) diff(y')'])
Label the x-axis from 0 to 1:
Nticks = 11;
xl = xlim;
set(gca, 'XTick', linspace(xl(1), xl(2), Nticks))
set(gca, 'XTickLabel', linspace(0, 1, Nticks))

Andy
Andy on 21 Feb 2013
Thank you that was just what i was after, all working now.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!