When do we use fill-between for line graphs in Matplotlib?

Question

When do we use fill-between for line graphs in Matplotlib?

Answer

Fill-between is used to let us see a possible range of upper and lower bounds that values might fall between, due to possible error or uncertainty. For example, showing historical data of temperature over several years, which can help us see what range of temperatures a location might fall in the future.

Another application of fill-between is when we want to create area plots, which show quantitative data over time. Additional applications are in stock price data, and in machine learning, such as for test data.

2 Likes

I don’t understand how 10% is translated to 1.1, when adding 10% to a number.

y_upper = [1.1 * i for i in revenue]

Can someone please help explain this. I thought adding 10% is 0.1 + NUMBER?

Let’s say the number you want to add 10% to is called i.

To add 10% to i, we would do 0.1 * i + i. We can rewrite this expression as the following:

0.1 * i + 1 * i = (0.1 + 1) * i = 1.1 * i

2 Likes

@rayedspat Ohhhh…ok that makes a lot more sense now! Thanks so much for explaining this.