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

End caps on barplot confidence intervals #606 update #898

Merged
merged 13 commits into from Apr 24, 2016

Conversation

dcgemperline
Copy link
Contributor

@dcgemperline dcgemperline commented Mar 31, 2016

I think this fixes the end cap addition to barplot and scatterplot confidence intervals. Let me know what you think. It should pass all the automated tests. Let me know if there is anything wrong. I've attached some images, along with the python script I used to generate them. This should show you what the different parameters look like for different capsize and conf_lw. Major thanks to jat255 who did the initial work on this. This is my very first contribution to an open source project that is not my own. Let me know if there is anything else that needs to be done as far as style and/or code cleanup.

import seaborn as sns

##LINEPLOTS

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
                   palette="YlGnBu_d", size=6, aspect=.75)
g.despine(left=True)
g.savefig("test1.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
                   palette="YlGnBu_d", size=6, aspect=.75, conf_lw=1, capsize=0.3)
g.despine(left=True)
g.savefig("test2.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
                   palette="YlGnBu_d", size=6, aspect=.75, conf_lw=4, capsize=0.3)
g.despine(left=True)
g.savefig("test2b.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
                   palette="YlGnBu_d", size=6, aspect=.75, conf_lw=1, capsize=0.1)
g.despine(left=True)
g.savefig("test3.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
                   palette="YlGnBu_d", size=6, aspect=.75, conf_lw=2, capsize=0.3)
g.despine(left=True)
g.savefig("test4.png")

##BarPlots

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
                   size=6, kind="bar", palette="muted")
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test5.png")

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
                   size=6, kind="bar", palette="muted", conf_lw=1, capsize=0.3)
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test6.png")

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
                   size=6, kind="bar", palette="muted", conf_lw=1, capsize=0.1)
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test7.png")

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
                   size=6, kind="bar", palette="muted", conf_lw=2, capsize=0.3)
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test8.png")

`

test1
test2
test2b
test3
test4
test5
test6
test7
test8

@mwaskom
Copy link
Owner

@mwaskom mwaskom commented Apr 6, 2016

Thanks for fixing the tests and getting this working in pointplot.

Please add some tests to cover this new behavior, though.

capsize=None,
**kws):

if conf_lw:
Copy link
Owner

@mwaskom mwaskom Apr 6, 2016

Choose a reason for hiding this comment

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

If you are testing against None, do so explicitly.

@mwaskom
Copy link
Owner

@mwaskom mwaskom commented Apr 6, 2016

I have made some comments. I would suggest writing the tests first before addressing them so that you can guard against introducing errors when fixing.

@dcgemperline
Copy link
Contributor Author

@dcgemperline dcgemperline commented Apr 6, 2016

Thanks for the quick feedback. This is my first time really writing python, so I appreciate the code review. I will see if I can implement the tests, check them in and then work on getting the changes you suggested in as well.

@dcgemperline
Copy link
Contributor Author

@dcgemperline dcgemperline commented Apr 7, 2016

Python script with some values adjusting the errwidth and the capsize

`import seaborn as sns

##LINEPLOTS

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
palette="YlGnBu_d", size=6, aspect=.75)
g.despine(left=True)
g.savefig("test1.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
palette="YlGnBu_d", size=6, aspect=.75, errwidth=1, capsize=0.3)
g.despine(left=True)
g.savefig("test2.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
palette="YlGnBu_d", size=6, aspect=.75, errwidth=4, capsize=0.3)
g.despine(left=True)
g.savefig("test2b.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
palette="YlGnBu_d", size=6, aspect=.75, errwidth=1, capsize=0.1)
g.despine(left=True)
g.savefig("test3.png")

g=None
sns.set(style="whitegrid")
df = sns.load_dataset("exercise")
g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=df,
palette="YlGnBu_d", size=6, aspect=.75, errwidth=2, capsize=0.3)
g.despine(left=True)
g.savefig("test4.png")

##BarPlots

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
size=6, kind="bar", palette="muted")
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test5.png")

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
size=6, kind="bar", palette="muted", errwidth=1, capsize=0.3)
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test6.png")

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
size=6, kind="bar", palette="muted", errwidth=1, capsize=0.1)
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test7.png")

g=None
sns.set(style="whitegrid")
titanic = sns.load_dataset("titanic")
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
size=6, kind="bar", palette="muted", errwidth=2, capsize=0.3)
g.despine(left=True)
g.set_ylabels("survival probability")
g.savefig("test8.png")
`

test1
test2
test2b
test3
test4
test5
test6
test7
test8

@dcgemperline
Copy link
Contributor Author

@dcgemperline dcgemperline commented Apr 14, 2016

I know you are quite busy, but does there need to be any more work done on this for it to be integrated?

@mwaskom
Copy link
Owner

@mwaskom mwaskom commented Apr 14, 2016

On a very quick review the code looks clean and your example plots look very thorough, but I'm waiting to get the time to actually play with it myself for a bit before hitting merge. I'll ping you if it needs any more changes.

@mwaskom mwaskom merged commit 9fbc9f7 into mwaskom:master Apr 24, 2016
1 check passed
@mwaskom
Copy link
Owner

@mwaskom mwaskom commented Apr 24, 2016

Thanks!

@dcgemperline
Copy link
Contributor Author

@dcgemperline dcgemperline commented Apr 24, 2016

No problem! Thanks for letting me contribute :)

@luthramanisha
Copy link

@luthramanisha luthramanisha commented Aug 14, 2019

In seaborn version 0.9.0, new plotting functions including relplot() are released. These still don't have attributes err_width and cap_size for end caps in type line plots with confidence intervals.

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

3 participants