DeepPupper / intro-data-capstone-musclehub

0 stars 0 forks source link

Remember to include 0 in all of our graphs #4

Open jmcrey opened 6 years ago

jmcrey commented 6 years ago

So, again, I love the way that the y-values are being calculated in all of these graphs. It is a beautiful in elegant way to generate these custom values instead of outright listing them.

That being said, it is important that we explicitly list all relevant data points starting from 0 in our graphs; otherwise, it could lead to faulty or misleading statistics in some cases. In fact, not starting from 0 is a trick used in the real world all the time to present data in a misleading way. So, pro tip: whenever you're reading a graph, check to see where the data starts and ends -- if it doesn't start from 0 and end at the max value, then it's probably not the whole story.

That being said, including 0 in our graph is super easy to do because of the way these y-values and labels are being generated (which, again, great job). All we have to do is change the range to start from 0 instead of 1. An example is provided below:

ax.set_yticks([y * 0.05 for y in range(0, 5)])
ax.set_yticklabels([str(yl * 5) + '%' for yl in range(0, 5)])

Of course, the range function starts from 0 by default; so, we can actually just change the function to be this:

ax.set_yticks([y * 0.05 for y in range(5)])
ax.set_yticklabels([str(yl * 5) + '%' for yl in range(5)])

For practice, try going back through the other two graphs and include 0 in the data.

Just a side note -- in this case, there shouldn't be much of any difference in the display of the data; but, it is always better to explicitly include 0 in our labels so there is no question about the validity of our data.