Azzera filtri
Azzera filtri

using area function - drawing below 0 of y axes

9 visualizzazioni (ultimi 30 giorni)
michael
michael il 31 Mag 2021
Risposto: Star Strider il 31 Mag 2021
Hi,
I have some graph. I'd like to plot an area (the orange one). I'm using area function for positive values. how can I use it for both positive and negative?
It shall be dynamically as each time the graph is changing based on the data.
The maximum and minimum values may be the max and min of the graph.

Risposte (2)

Jan
Jan il 31 Mag 2021
This sounds like a job for a patch:
figure;
axes('XLim', [0, 10], 'Ylim', [-5, 5]);
patch([1,2,2,1], [-3,-3, 4,4], rand(1,3))

Star Strider
Star Strider il 31 Mag 2021
To do this with the area function, changing the basevalue could work, however it is likely easier to use patch
x = linspace(0,10);
y = sin(2*pi*x/5);
figure
patch([4 6 6 4], [-1 -1 1 1]*1.2, [.8 .3 .2], 'EdgeColor','none')
hold on
plot(x, y)
hold off
yline(0)
ylim([-1.5 1.5])
.

Categorie

Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by