Adding error bars to a line graph with ggplot2 in RRotating and spacing axis labels in ggplot2Plot two graphs in same plot in RPlotting two variables as lines using ggplot2 on the same graphOrder Bars in ggplot2 bar graphHow can we make xkcd style graphs?Give color to scatter plot points based on value thersholdTurn each row of data into individual line with ggplotPlot using mean and standard error values using ggplot2Add a geom_rect to the plot background (not panel) in ggplot2Adding error bars to a ggplot with reshaped data
Why wear sunglasses in indoor velodromes?
How can sister protect herself from impulse purchases with a credit card?
How come Arya Stark wasn't hurt by this in Game of Thrones Season 8 Episode 5?
I recently started my machine learning PhD and I have absolutely no idea what I'm doing
Who is frowning in the sentence "Daisy looked at Tom frowning"?
What should I wear to go and sign an employment contract?
Have GoT's showrunners reacted to the poor reception of the final season?
FIFO data structure in pure C
Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?
Referring to a character in 3rd person when they have amnesia
Can a generation ship withstand its own oxygen and daily wear for many thousands of years?
Bookshelves: the intruder
Is it a good idea to teach algorithm courses using pseudocode?
What would be the game balance implications for using the Gygax method for applying falling damage?
Why does a table with a defined constant in its index compute 10X slower?
Why does string strummed with finger sound different from the one strummed with pick?
Why are stats in Angband written as 18/** instead of 19, 20...?
Are there any symmetric cryptosystems based on computational complexity assumptions?
How do you cope with rejection?
Is it possible to determine from only a photo of a cityscape whether it was taken close with wide angle or from a distance with zoom?
Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?
Physically unpleasant work environment
Does the usage of mathematical symbols work differently in books than in theses?
Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario
Adding error bars to a line graph with ggplot2 in R
Rotating and spacing axis labels in ggplot2Plot two graphs in same plot in RPlotting two variables as lines using ggplot2 on the same graphOrder Bars in ggplot2 bar graphHow can we make xkcd style graphs?Give color to scatter plot points based on value thersholdTurn each row of data into individual line with ggplotPlot using mean and standard error values using ggplot2Add a geom_rect to the plot background (not panel) in ggplot2Adding error bars to a ggplot with reshaped data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have three y values corresponding to three x values. I just want to have a line graph between these three dots
g <- c("1","2","3")
i <- c(181.83,178.74,152.02)
df <- data.frame(g,i)
p <- ggplot(df, aes(x=g, y=i)) + geom_line() + geom_point()
Using this I get this:
First of all why does my geom_line() not work? After that I have:
se <- c(22.95,22.72,19.2)
p + geom_errorbar(aes(ymin=se,ymax=se))
And what I get is:
Why are my errorbars not centered around the data points? Why are they smushed to the bottom? Why do they seem horizontal? What can I do to fix this?
r ggplot2 graphing errorbar
add a comment |
I have three y values corresponding to three x values. I just want to have a line graph between these three dots
g <- c("1","2","3")
i <- c(181.83,178.74,152.02)
df <- data.frame(g,i)
p <- ggplot(df, aes(x=g, y=i)) + geom_line() + geom_point()
Using this I get this:
First of all why does my geom_line() not work? After that I have:
se <- c(22.95,22.72,19.2)
p + geom_errorbar(aes(ymin=se,ymax=se))
And what I get is:
Why are my errorbars not centered around the data points? Why are they smushed to the bottom? Why do they seem horizontal? What can I do to fix this?
r ggplot2 graphing errorbar
You can fix the first problem with addinggroup = 1
like thisggplot(df, aes(x = g, y = i, group = 1)) + geom_line() + geom_point()
– kath
Mar 23 at 17:36
Thank you so much! Should I edit out that part of the question because it's resolved?
– YarkınErgin
Mar 23 at 17:46
add a comment |
I have three y values corresponding to three x values. I just want to have a line graph between these three dots
g <- c("1","2","3")
i <- c(181.83,178.74,152.02)
df <- data.frame(g,i)
p <- ggplot(df, aes(x=g, y=i)) + geom_line() + geom_point()
Using this I get this:
First of all why does my geom_line() not work? After that I have:
se <- c(22.95,22.72,19.2)
p + geom_errorbar(aes(ymin=se,ymax=se))
And what I get is:
Why are my errorbars not centered around the data points? Why are they smushed to the bottom? Why do they seem horizontal? What can I do to fix this?
r ggplot2 graphing errorbar
I have three y values corresponding to three x values. I just want to have a line graph between these three dots
g <- c("1","2","3")
i <- c(181.83,178.74,152.02)
df <- data.frame(g,i)
p <- ggplot(df, aes(x=g, y=i)) + geom_line() + geom_point()
Using this I get this:
First of all why does my geom_line() not work? After that I have:
se <- c(22.95,22.72,19.2)
p + geom_errorbar(aes(ymin=se,ymax=se))
And what I get is:
Why are my errorbars not centered around the data points? Why are they smushed to the bottom? Why do they seem horizontal? What can I do to fix this?
r ggplot2 graphing errorbar
r ggplot2 graphing errorbar
edited Mar 23 at 17:35
kath
5,0231026
5,0231026
asked Mar 23 at 17:30
YarkınErginYarkınErgin
1
1
You can fix the first problem with addinggroup = 1
like thisggplot(df, aes(x = g, y = i, group = 1)) + geom_line() + geom_point()
– kath
Mar 23 at 17:36
Thank you so much! Should I edit out that part of the question because it's resolved?
– YarkınErgin
Mar 23 at 17:46
add a comment |
You can fix the first problem with addinggroup = 1
like thisggplot(df, aes(x = g, y = i, group = 1)) + geom_line() + geom_point()
– kath
Mar 23 at 17:36
Thank you so much! Should I edit out that part of the question because it's resolved?
– YarkınErgin
Mar 23 at 17:46
You can fix the first problem with adding
group = 1
like this ggplot(df, aes(x = g, y = i, group = 1)) + geom_line() + geom_point()
– kath
Mar 23 at 17:36
You can fix the first problem with adding
group = 1
like this ggplot(df, aes(x = g, y = i, group = 1)) + geom_line() + geom_point()
– kath
Mar 23 at 17:36
Thank you so much! Should I edit out that part of the question because it's resolved?
– YarkınErgin
Mar 23 at 17:46
Thank you so much! Should I edit out that part of the question because it's resolved?
– YarkınErgin
Mar 23 at 17:46
add a comment |
1 Answer
1
active
oldest
votes
Alright I figured it out: the ymin
and ymax
arguments are telling where the error line starts and ends quite literally, so you can't just put the real standard error value and expect ggplot2
to figure out where will this error line be centered. So you have to specify it as:
geom_errobar(aes(ymin = i - se, ymax = i + se))
And finally you get:
Hope it helps others as well.
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%2f55316493%2fadding-error-bars-to-a-line-graph-with-ggplot2-in-r%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
Alright I figured it out: the ymin
and ymax
arguments are telling where the error line starts and ends quite literally, so you can't just put the real standard error value and expect ggplot2
to figure out where will this error line be centered. So you have to specify it as:
geom_errobar(aes(ymin = i - se, ymax = i + se))
And finally you get:
Hope it helps others as well.
add a comment |
Alright I figured it out: the ymin
and ymax
arguments are telling where the error line starts and ends quite literally, so you can't just put the real standard error value and expect ggplot2
to figure out where will this error line be centered. So you have to specify it as:
geom_errobar(aes(ymin = i - se, ymax = i + se))
And finally you get:
Hope it helps others as well.
add a comment |
Alright I figured it out: the ymin
and ymax
arguments are telling where the error line starts and ends quite literally, so you can't just put the real standard error value and expect ggplot2
to figure out where will this error line be centered. So you have to specify it as:
geom_errobar(aes(ymin = i - se, ymax = i + se))
And finally you get:
Hope it helps others as well.
Alright I figured it out: the ymin
and ymax
arguments are telling where the error line starts and ends quite literally, so you can't just put the real standard error value and expect ggplot2
to figure out where will this error line be centered. So you have to specify it as:
geom_errobar(aes(ymin = i - se, ymax = i + se))
And finally you get:
Hope it helps others as well.
edited Mar 23 at 19:42
markus
16.8k21438
16.8k21438
answered Mar 23 at 18:05
YarkınErginYarkınErgin
1
1
add a comment |
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%2f55316493%2fadding-error-bars-to-a-line-graph-with-ggplot2-in-r%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
You can fix the first problem with adding
group = 1
like thisggplot(df, aes(x = g, y = i, group = 1)) + geom_line() + geom_point()
– kath
Mar 23 at 17:36
Thank you so much! Should I edit out that part of the question because it's resolved?
– YarkınErgin
Mar 23 at 17:46