Changing distance between categories when plotting FacetGrid with error barsHow to change the font size on a matplotlib plotWhen to use cla(), clf() or close() for clearing a plot in matplotlib?pandas plots on Seaborn FacetGridHow to add legend on Seaborn facetgrid bar plotIncrease space between rows on FacetGrid plotPython: Plot scatter plot with category and markersizePlotting mean lines for different 'hue' data on a Seaborn FacetGrid plotSeaborn FacetGrid legend loses linestyle details when changing linewidthseaborn bar chart for categorical data, groupedHow to add a comparison line to all plots when using Seaborn's FacetGrid
Will using a resistor in series with a LED to control its voltage increase the total energy expenditure?
Why does my purified Pokémon need to be healed?
Why did IBM make public the PC BIOS source code?
Simplification of numbers
What are those bumps on top of the Antonov-225?
Do Reform Jews believe in a theistic God?
If you know the location of an invisible creature, can you attack it?
How can God warn people of the upcoming rapture without disrupting society?
Boss asked a co-worker to assault me
How was the murder committed?
The cat exchanges places with a drawing of the cat
How far did Gandalf and the Balrog drop from the bridge in Moria?
Are those flyers about apartment purchase a scam?
Concat Loop Results to determine if contains value
How do I call a 6 digit Austrailian phone number with a US based mobile phone?
PhD advisor lost funding, need advice
Modeling the uncertainty of the input parameters
Does one make a shehecheyanu on "used" jewelry?
How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?
What kind of liquid can be seen 'leaking' from the upper surface of the wing of a Boeing 737-800?
Telephone number in spoken words
Can the IPA represent all languages' tones?
Using hearing aids on the sabbath?
Help, I cannot decide when to start the story
Changing distance between categories when plotting FacetGrid with error bars
How to change the font size on a matplotlib plotWhen to use cla(), clf() or close() for clearing a plot in matplotlib?pandas plots on Seaborn FacetGridHow to add legend on Seaborn facetgrid bar plotIncrease space between rows on FacetGrid plotPython: Plot scatter plot with category and markersizePlotting mean lines for different 'hue' data on a Seaborn FacetGrid plotSeaborn FacetGrid legend loses linestyle details when changing linewidthseaborn bar chart for categorical data, groupedHow to add a comparison line to all plots when using Seaborn's FacetGrid
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).
I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
cat = ['a','b','a','a','a','b','b','a']
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
plt.show()
python matplotlib seaborn errorbar facet-grid
add a comment |
I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).
I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
cat = ['a','b','a','a','a','b','b','a']
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
plt.show()
python matplotlib seaborn errorbar facet-grid
add a comment |
I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).
I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
cat = ['a','b','a','a','a','b','b','a']
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
plt.show()
python matplotlib seaborn errorbar facet-grid
I am using FacetGrid from Seaborn together with errorbar from Matplotlib to generate a graph that has two categories in the y axis. I want to center the two categories (get them closer to each other and more distant to the margins).
I have tried to change height/aspect to achieve that without success. I am sharing the code below. Thanks!
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
cat = ['a','b','a','a','a','b','b','a']
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
plt.show()
python matplotlib seaborn errorbar facet-grid
python matplotlib seaborn errorbar facet-grid
edited Mar 28 at 1:11
Daniela Osorio
asked Mar 26 at 23:18
Daniela OsorioDaniela Osorio
11 bronze badge
11 bronze badge
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You are pretty close to it
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# replace label with actual number
cat = [1,2,1,1,1,2,2,1]
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
# place the ticks at center by widening the plot
plt.xlim((0, 3))
# fix ticks at the number encoding for each class
g.fig.axes[0].xaxis.set_ticks([1, 2])
# name the numbers
g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
plt.show()
The trick is to make use of relative length of the x-limit and your number encoding for the classes.
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%2f55367551%2fchanging-distance-between-categories-when-plotting-facetgrid-with-error-bars%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
You are pretty close to it
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# replace label with actual number
cat = [1,2,1,1,1,2,2,1]
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
# place the ticks at center by widening the plot
plt.xlim((0, 3))
# fix ticks at the number encoding for each class
g.fig.axes[0].xaxis.set_ticks([1, 2])
# name the numbers
g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
plt.show()
The trick is to make use of relative length of the x-limit and your number encoding for the classes.
add a comment |
You are pretty close to it
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# replace label with actual number
cat = [1,2,1,1,1,2,2,1]
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
# place the ticks at center by widening the plot
plt.xlim((0, 3))
# fix ticks at the number encoding for each class
g.fig.axes[0].xaxis.set_ticks([1, 2])
# name the numbers
g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
plt.show()
The trick is to make use of relative length of the x-limit and your number encoding for the classes.
add a comment |
You are pretty close to it
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# replace label with actual number
cat = [1,2,1,1,1,2,2,1]
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
# place the ticks at center by widening the plot
plt.xlim((0, 3))
# fix ticks at the number encoding for each class
g.fig.axes[0].xaxis.set_ticks([1, 2])
# name the numbers
g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
plt.show()
The trick is to make use of relative length of the x-limit and your number encoding for the classes.
You are pretty close to it
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# replace label with actual number
cat = [1,2,1,1,1,2,2,1]
var=[3,5,4,6,7,5,6,3]
sd_var = [0.1,0.3,0.1,0.5,0.4,0.2,0.1,0.2]
df = pd.DataFrame('cat' : cat, 'var' : var, 'sd_var' : sd_var)
g = sns.FacetGrid(data=df, hue="cat", aspect=1, height=6)
g.map(plt.errorbar, "cat", "var", "sd_var", marker="o",
linestyle='',markersize='6', capsize=4, elinewidth=2)
# place the ticks at center by widening the plot
plt.xlim((0, 3))
# fix ticks at the number encoding for each class
g.fig.axes[0].xaxis.set_ticks([1, 2])
# name the numbers
g.fig.axes[0].xaxis.set_ticklabels(['a', 'b'])
plt.show()
The trick is to make use of relative length of the x-limit and your number encoding for the classes.
answered Mar 28 at 1:29
PM HuiPM Hui
1566 bronze badges
1566 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55367551%2fchanging-distance-between-categories-when-plotting-facetgrid-with-error-bars%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