# Storytelling Data Visualization: Completing the progress bar

https://app.dataquest.io/m/526/storytelling-data-visualization/8/completing-the-progress-bar

I do not understand the logic behind this - * `xmax_vals`: the values we’ll need to use for the `xmax` parameter of `Axes.axhline()` to control its length. We multiplied each proportion by `0.3` because `xmax - xmin = 0.8 - 0.5 = 0.3`. Why do we need to multiply it with 0.3 ?

Here is the actual section of code. Also, could please someone share more information / tutorial on the for loop used in the code below ?

My Code:

``````deaths = [2398, 126203, 227178, 295406]
proportions = [round(death/295406, 2) for death in deaths]
xmax_vals = [round(0.5 + proportion * 0.3, 3) for proportion in proportions]
``````

Hi!
The objective of this mission is to fill the progress on the progress line by trimestre. On the plot, the progress line starts at `x=0.5` and finishes at `x=0.8`, so its length is 0.8 - 0.5 = 0.3. We are to fill it with the `proportions` value which is accumulated number of death by trimester to the total number of death in the year. The last trimestre is the most illustrative one. The `proportion` value is `1`. We have to fit this value on a line with the length of 0.3. How do we do this? Right, by multiplying by 0.3. And if we assumed that in the first trimester half of the total deaths occured, we would have to do some proportion calculations to define the lengths of the color line: The `1` value fills the length of 0.3. What would be the length of `0.5` value?0.5 * 0.3 / 1 which is equivalent to 0.5 * 0.3

As for the for-loops used in the code, it’s a one-line shortcut syntax for creating a list using for-loop, which is called list comprehension. In the traditional way the same code would look like this:

``````proportions = []
for death in deaths:
proportion = round(death/295406, 2)
proportions.append(proportion)
``````
4 Likes

Thanks a lot, totally make sense now. I think would be a good idea if Dataquest gave some introduction before using a one-line shortcut syntax like they did in this lesson. It can save a lot of time for us learners. I know you posted the link for List Comprehension but that topic is way down the list and Dataquest already used it here without any introduction.

1 Like

Completely agree with you on using the syntax which haven’t been introduced yet. This course has been updated recently. The contents are completely brand new. I haven’t done it yet, but from what I’ve seen in the Community, it’s a way better than the old one from the point of view of data visualisation and its interpretation. But probably some detailes have escaped from them. What do you think, @Sahil ?

oh ya this new one is much much better. The new one came in right after I finished the old one, and I was like oh GOD I just finished it but I am now happy redoing it.

3 Likes

Commenting 5 months later… let me also add the concepts which slowed me down in data viz and can be added to DQ or built-in as part of hands-on or links to reading material or videos elsewhere

1. packing and unpacking - used when assigned sub-plots to axes
2. a more comprehensive course on OOO to build intuition, if not technical knowledge
3. sets ( not really used in missions, but it was missed out as part of data structures)
4. data coordinates and display coordinates
5. algorithms