Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update histograms.md #2242

Merged
merged 2 commits into from
Mar 6, 2020
Merged

Update histograms.md #2242

merged 2 commits into from
Mar 6, 2020

Conversation

SylwiaOliwia2
Copy link
Contributor

Added Accessing the y-axis values section

Added `Accessing the y-axis values` section
@SylwiaOliwia2 SylwiaOliwia2 mentioned this pull request Mar 3, 2020
13 tasks
@@ -69,6 +69,32 @@ fig = px.histogram(df, x="total_bill", nbins=20)
fig.show()
```

#### Accessing the y-axis values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Accessing the counts (y-axis) values?

@emmanuelle
Copy link
Contributor

Thank you for the example @SylwiaOliwia2 ! A lot of people get confused about this, it will be very useful. I'm just curious to know why you used pandas functions instead of np.histogram, is it because some people working with pandas prefer to use only pandas functions? I post below a version using np.histogram so that we can compare and discuss about the two solutions.

import plotly.express as px
import numpy as np
df = px.data.tips()
# create the bins
counts, bins = np.histogram(df.total_bill, bins=range(0, 60, 5))
bins = 0.5 * (bins[:-1] + bins[1:])
fig = px.bar(x=bins, y=counts, labels={'x':'total_bill', 'y':'count'})
fig.show()

@SylwiaOliwia2
Copy link
Contributor Author

Indeed, I used to pandas, this solution was the most obvious solution to me.
However, numpy.histogram is much simpler and using continuous x-scale! If you agree I'll keep only the NumPy solution.

@emmanuelle
Copy link
Contributor

@SylwiaOliwia2 I agree that I find the numpy solution simpler.

'Accessing the counts (y-axis) values' - use example with numpy instead of pandas
@SylwiaOliwia2
Copy link
Contributor Author

@emmanuelle done :)

@emmanuelle
Copy link
Contributor

Thank you @SylwiaOliwia2 ! Now that you have contributed several doc PRs to plotly.py, do you have any feedback about the contribution process? Any way that we could improve it? Do you feel like trying to work on a bug or a part of the code for your next PR ;-) ? Great to have here anyway!

@emmanuelle emmanuelle merged commit d6d6aa3 into plotly:doc-prod Mar 6, 2020
@SylwiaOliwia2
Copy link
Contributor Author

Thank you @SylwiaOliwia2 ! Now that you have contributed several doc PRs to plotly.py, do you have any feedback about the contribution process? Any way that we could improve it? Do you feel like trying to work on a bug or a part of the code for your next PR ;-) ? Great to have here anyway!

Thank you, @emmanuelle :) Definitely I can try working out on the code the next time. Feel free to suggest any issue :)

Regarding contribution, using tags is very helpful (that's how I've found the issue), especially for newbies. So keep using them, please ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants