Seaborn swarmplot and pointplot dodge alignment
I am plotting this:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1)
n=200
to_plot = np.random.uniform(low=0.0, high=1.0, size=n)
mods = ['a','b']
model_col = mods*(n/2)
opt=['1']*(n/2)+['2']*(n/2)
d={'Model':pd.Series(model_col),'Par':pd.Series(to_plot),'opt':pd.Series(opt)}
df = pd.DataFrame(d)
sns.swarmplot(x='Model', y='Par',hue='opt',dodge=True,data=df,size=2,palette=['#469990','#000075'])
sns.pointplot(x="Model", y="Par", hue='opt', data=df,join=False,dodge=True,
ci=68,n_boot=1000,capsize=0.1,errwidth=0.5,scale = 1.5,palette=['k','k'])
ax.get_legend().remove()
plt.show()

Is there a way to align the pointplot mean+SEM and the corresponding swarmplot?
plot seaborn
add a comment |
I am plotting this:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1)
n=200
to_plot = np.random.uniform(low=0.0, high=1.0, size=n)
mods = ['a','b']
model_col = mods*(n/2)
opt=['1']*(n/2)+['2']*(n/2)
d={'Model':pd.Series(model_col),'Par':pd.Series(to_plot),'opt':pd.Series(opt)}
df = pd.DataFrame(d)
sns.swarmplot(x='Model', y='Par',hue='opt',dodge=True,data=df,size=2,palette=['#469990','#000075'])
sns.pointplot(x="Model", y="Par", hue='opt', data=df,join=False,dodge=True,
ci=68,n_boot=1000,capsize=0.1,errwidth=0.5,scale = 1.5,palette=['k','k'])
ax.get_legend().remove()
plt.show()

Is there a way to align the pointplot mean+SEM and the corresponding swarmplot?
plot seaborn
add a comment |
I am plotting this:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1)
n=200
to_plot = np.random.uniform(low=0.0, high=1.0, size=n)
mods = ['a','b']
model_col = mods*(n/2)
opt=['1']*(n/2)+['2']*(n/2)
d={'Model':pd.Series(model_col),'Par':pd.Series(to_plot),'opt':pd.Series(opt)}
df = pd.DataFrame(d)
sns.swarmplot(x='Model', y='Par',hue='opt',dodge=True,data=df,size=2,palette=['#469990','#000075'])
sns.pointplot(x="Model", y="Par", hue='opt', data=df,join=False,dodge=True,
ci=68,n_boot=1000,capsize=0.1,errwidth=0.5,scale = 1.5,palette=['k','k'])
ax.get_legend().remove()
plt.show()

Is there a way to align the pointplot mean+SEM and the corresponding swarmplot?
plot seaborn
I am plotting this:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots(nrows=1, ncols=1)
n=200
to_plot = np.random.uniform(low=0.0, high=1.0, size=n)
mods = ['a','b']
model_col = mods*(n/2)
opt=['1']*(n/2)+['2']*(n/2)
d={'Model':pd.Series(model_col),'Par':pd.Series(to_plot),'opt':pd.Series(opt)}
df = pd.DataFrame(d)
sns.swarmplot(x='Model', y='Par',hue='opt',dodge=True,data=df,size=2,palette=['#469990','#000075'])
sns.pointplot(x="Model", y="Par", hue='opt', data=df,join=False,dodge=True,
ci=68,n_boot=1000,capsize=0.1,errwidth=0.5,scale = 1.5,palette=['k','k'])
ax.get_legend().remove()
plt.show()

Is there a way to align the pointplot mean+SEM and the corresponding swarmplot?
plot seaborn
plot seaborn
asked Jan 19 at 23:33
AleAle
465
465
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It seems swarmplot and pointplot use different defaults for their respective dodge paramter. However you may set them to equal values, e.g.
sns.swarmplot(..., dodge=0.4)
sns.pointplot(..., dodge=0.4)
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54272277%2fseaborn-swarmplot-and-pointplot-dodge-alignment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems swarmplot and pointplot use different defaults for their respective dodge paramter. However you may set them to equal values, e.g.
sns.swarmplot(..., dodge=0.4)
sns.pointplot(..., dodge=0.4)
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
add a comment |
It seems swarmplot and pointplot use different defaults for their respective dodge paramter. However you may set them to equal values, e.g.
sns.swarmplot(..., dodge=0.4)
sns.pointplot(..., dodge=0.4)
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
add a comment |
It seems swarmplot and pointplot use different defaults for their respective dodge paramter. However you may set them to equal values, e.g.
sns.swarmplot(..., dodge=0.4)
sns.pointplot(..., dodge=0.4)
It seems swarmplot and pointplot use different defaults for their respective dodge paramter. However you may set them to equal values, e.g.
sns.swarmplot(..., dodge=0.4)
sns.pointplot(..., dodge=0.4)
answered Jan 20 at 22:15
ImportanceOfBeingErnestImportanceOfBeingErnest
131k13143218
131k13143218
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
add a comment |
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
God, can't believe I missed that..... Thank you so much!
– Ale
Jan 21 at 16:04
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54272277%2fseaborn-swarmplot-and-pointplot-dodge-alignment%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown