Skip to content

Commit 9e3df43

Browse files
Merge branch 'doc-prod'
2 parents 1c99b99 + e2886e8 commit 9e3df43

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

doc/python/histograms.md

+17
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ fig = px.histogram(df, x="total_bill", nbins=20)
6969
fig.show()
7070
```
7171

72+
#### Accessing the counts (y-axis) values
73+
74+
JavaScript calculates the y-axis (count) values on the fly in the browser, so it's not accessible in the `fig`. You can manually calculate it using `np.histogram`.
75+
76+
```python
77+
import plotly.express as px
78+
import numpy as np
79+
80+
df = px.data.tips()
81+
# create the bins
82+
counts, bins = np.histogram(df.total_bill, bins=range(0, 60, 5))
83+
bins = 0.5 * (bins[:-1] + bins[1:])
84+
85+
fig = px.bar(x=bins, y=counts, labels={'x':'total_bill', 'y':'count'})
86+
fig.show()
87+
```
88+
7289
#### Type of normalization
7390

7491
The default mode is to represent the count of samples in each bin. With the `histnorm` argument, it is also possible to represent the percentage or fraction of samples in each bin (`histnorm='percent'` or `probability`), or a density histogram (the sum of bars is equal to 100, `density`), or a probability density histogram (sum equal to 1, `probability density`).

doc/python/sunburst-charts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
326326
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
327327
for i, level in enumerate(levels):
328328
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
329-
dfg = df.groupby(levels[i:]).sum(numerical_only=True)
329+
dfg = df.groupby(levels[i:]).sum()
330330
dfg = dfg.reset_index()
331331
df_tree['id'] = dfg[level].copy()
332332
if i < len(levels) - 1:

doc/python/treemaps.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
278278
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
279279
for i, level in enumerate(levels):
280280
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
281-
dfg = df.groupby(levels[i:]).sum(numerical_only=True)
281+
dfg = df.groupby(levels[i:]).sum()
282282
dfg = dfg.reset_index()
283283
df_tree['id'] = dfg[level].copy()
284284
if i < len(levels) - 1:

0 commit comments

Comments
 (0)