Why do we add 0.5 when calculating xmax_vals?

Screen Link:

Storytelling Data Visualization | Dataquest

I don’t understand 0.5 that is included as part of xmax-vals.
Someone else has asked this on a different question, and the response was the 0.5 is the assumption that half of the deaths occured in the first trimester. Two queries here:

  1. Is that given in the mission that half of deaths occured in tri-sem, as i couldn’t find it &
  2. deaths at the end of first tri-sem are 2398, that can’t be half of the total deaths, so how is that 0.5 ?

death_toll = pd.read_csv(‘covid_avg_deaths.csv’)
deaths = [2398, 126203, 227178, 295406]
proportions = [round(death/295406, 2) for death in deaths] # list comprehension
xmax_vals = [round(0.5 + proportion * 0.3, 3) for proportion in proportions]

I think you misunderstood the statement in the answer you are referring to.

But, regardless, xmin and xmax help us define the length of our line. When we want to create that line for multiple plots, we simply loop through the plots to add those lines.

That’s what the code does -

for ax, xmax, death in zip(axes, xmax_vals, deaths):
    ax.axhline(y=1600, xmin=0.5, xmax=xmax,
               linewidth=6, color='#af0b1e')

xmin is where the line starts - at 0.5. And xmax is where the line ends.

Therefore, the length of the line is xmax - xmin

When we are creating the line corresponding to our progress bar, we only know the length and where it should start (xmin)

So, if we only know the length and we know it starts at xmin, how do we calculate xmax?

Simple,

xmax = xmin + length

Which is

xmax = 0.5 + length

and our length is obtained from proportion * 0.3.

That’s why we have a 0.5. It just represents where the line starts.

thank you ! that’s right xmax is the value of the coordinate and that’s why proportion is to be added to the starting x-value of the bar (xmin) i.e. 0.5 to plot the point of quarterly progress. I was incorrectly thinking of xmax as the proportion value only.