Filter löschen
Filter löschen

Area plot style graph

1 Ansicht (letzte 30 Tage)
Andy
Andy am 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

Antworten (2)

Thorsten
Thorsten am 21 Feb. 2013
Bearbeitet: Thorsten am 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 am 21 Feb. 2013
Thank you that was just what i was after, all working now.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by