bug
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- numpy, pandas, python
- Domain
- data-visualization, documentation
Research direction
The issue points to the Graph Gallery's “Show Number of Observations” Python example; start by checking the boxplot setup and the later ax.get_xticklabels() use. Confirm the example runs and renders the observation-count labels, then inspect other Python examples for the same reported mistake.
Written by the indexing model from the issue text.
Description
Hi Yan,
in the Graph Gallery in some example in Python there are mistakes
for example in the "Show Number of Observations"
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import pandas as pd
Dataset:
a = pd.DataFrame({ 'group' : np.repeat('A',500), 'value': np.random.normal(10, 5, 500) })
b = pd.DataFrame({ 'group' : np.repeat('B',500), 'value': np.random.normal(13, 1.2, 500) })
c = pd.DataFrame({ 'group' : np.repeat('B',500), 'value': np.random.normal(18, 1.2, 500) })
d = pd.DataFrame({ 'group' : np.repeat('C',20), 'value': np.random.normal(25, 4, 20) })
e = pd.DataFrame({ 'group' : np.repeat('D',100), 'value': np.random.uniform(12, size=100) })
df = pd.concat([a,b,c,d,e])
Start with a basic boxplot
sns.boxplot(x="group", y="value", data=df) # the assignment ax is missing
Calculate number of obs per group & median to position labels
medians = df.groupby(['group'])['value'].median().values
nobs = df.groupby("group").size().values
nobs = [str(x) for x in nobs.tolist()]
nobs = ["n: " + i for i in nobs]
Add it to the plot
pos = range(len(nobs))
for tick,label in zip(pos,ax.get_xticklabels()):
plt.text(pos[tick], medians[tick] + 0.4, nobs[tick], horizontalalignment='center', size='medium', color='w', weight='semibold')
add title
plt.title("Boxplot with number of observation", loc="left")
show the graph
plt.show()
================
Best regards
--Marco
- Dominant language
- HTML
- Stars
- 2.3k
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from holtzy/The-Python-Graph-Gallery
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
holtzy/The-Python-Graph-Gallery#542 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
tutorial to addOpen
Difficulty 3/5 1-2 days Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
All issues in holtzy/The-Python-Graph-Gallery
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
OHDSI/Data2Evidence#3796 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Openpanel-dev/openpanel#694 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
easystats/performance#1038 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 2 days