Week 2 Lab: Exploratory Data Analysis - Data Visualization and Summary Statistics

Dear Mentor,

Could you please guide me how to calculate the scale number of the colorbar when density is true?

If Density = False, range is from 0 to 20000+

hist = ax.hist2d(longitude, latitude, bins=50, density=False)

If Density = True, range is from 0 to 600+

hist = ax.hist2d(longitude, latitude, bins=50, density=True)

Length of longitude = Length of latitude = 575485
According to matplotlib,

density = counts / (sum(counts) * np.diff(bins))

I assume that
sum(counts) = 575485
count = 20000 (estimated from the first figure)
bin width = 0.05 / 6 = 0.008 (estimated)
density = 20000 / (575485 * 0.008) = 4.344 (This is not 600 from the second figure)

and also

I thought that the probability density must be within 0 to 1 but it shows that a range from 0 to 600+

Please correct me for any mistakes.

Thank you.

Where did your equation for density come from?

Dear Mr Tom Mosher,

The equation for density is taken from matplotlib documentation.

→ density : bool, default: False


Thank you.

You mentioned a specific lab in the thread title. I went to that lab to see about getting more information on this issue.

The lab I see by that name in the course does not generate the plot you posted.

So I am confused.

Dear Mr Tom Mosher,

Please refer to this link to access the lab, and proceed to the Section “4. Check the Locations of Rides”

Thank you.

Thanks for the link.
Why is that lab name not in the title of the thread?

Dear Mr Tom Mosher,

I’m sorry for the inconvenience caused. I have updated the title of the thread.

Thank you.