# How can I fill the area between a function and the vertical axis x = 0, either for positive or negative values of it?

4 views (last 30 days)
OSCAR ZAMORA PICAZO on 17 Mar 2016
Answered: Mike Garrity on 17 Mar 2016

I have several diagrams which plot one function. I want to fill an area between that function (lineal, curve..)and a the vertical axis x = 0. So, how can I fill the area, either for positive or negative values of it?

The function is a piecewise function. The code of one case is:

``` y_B1 = 0:0.01:h_poste;
figure
ley_Mz_B1 = plot(Mz_B1,y_B1);grid;
title('CASO DE CARGA B (Viento 1).Ley de esfuerzos flectores')
xlabel('Momento flector Mz (N·m)');
ylabel('Altura (m)');```

where Mz_B1 is the function represented and y_B1 is the vector of independent values.

NOTE: the black area has been made using Paint.

Mike Garrity on 17 Mar 2016
This post I did on the MATLAB Graphics blog might give you some ideas on how to do this.

### Categories

Find more on Polygons in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by