Force R to stop plotting abbreviated axis labels - e.g. 1e+00 in ggplot2
In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01
along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10
.
Any help much appreciated.
r graph ggplot2 axes
add a comment |
In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01
along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10
.
Any help much appreciated.
r graph ggplot2 axes
add a comment |
In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01
along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10
.
Any help much appreciated.
r graph ggplot2 axes
In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01
along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10
.
Any help much appreciated.
r graph ggplot2 axes
r graph ggplot2 axes
asked Jan 28 '13 at 14:17
JPDJPD
76631124
76631124
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
I think you are looking for this:
require(ggplot2)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# displays x-axis in scientific notation
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p
# displays as you require
require(scales)
p + scale_x_continuous(labels = comma)
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
1
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
add a comment |
Did you try something like :
options(scipen=10000)
before plotting ?
2
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
add a comment |
Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to
+ scale_x_continuous(labels = scales::comma)
add a comment |
As a more general solution, you can use scales::format_format
to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma
which only does comma separations of the orders of magnitude.
For example:
require(ggplot2)
require(scales)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# Here we define spaces as the big separator
point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)
# Plot it
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p + scale_x_continuous(labels = point)
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%2f14563989%2fforce-r-to-stop-plotting-abbreviated-axis-labels-e-g-1e00-in-ggplot2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think you are looking for this:
require(ggplot2)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# displays x-axis in scientific notation
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p
# displays as you require
require(scales)
p + scale_x_continuous(labels = comma)
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
1
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
add a comment |
I think you are looking for this:
require(ggplot2)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# displays x-axis in scientific notation
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p
# displays as you require
require(scales)
p + scale_x_continuous(labels = comma)
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
1
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
add a comment |
I think you are looking for this:
require(ggplot2)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# displays x-axis in scientific notation
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p
# displays as you require
require(scales)
p + scale_x_continuous(labels = comma)
I think you are looking for this:
require(ggplot2)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# displays x-axis in scientific notation
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p
# displays as you require
require(scales)
p + scale_x_continuous(labels = comma)
edited Jan 30 at 20:42
Dave Jarvis
21.1k30132256
21.1k30132256
answered Jan 28 '13 at 14:23
ArunArun
93.6k11218319
93.6k11218319
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
1
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
add a comment |
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
1
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?
– JPD
Jan 28 '13 at 14:28
1
1
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.
– Marta Karas
Jul 30 '14 at 10:42
add a comment |
Did you try something like :
options(scipen=10000)
before plotting ?
2
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
add a comment |
Did you try something like :
options(scipen=10000)
before plotting ?
2
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
add a comment |
Did you try something like :
options(scipen=10000)
before plotting ?
Did you try something like :
options(scipen=10000)
before plotting ?
answered Jan 28 '13 at 14:19
jubajuba
34.5k888100
34.5k888100
2
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
add a comment |
2
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
2
2
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804
– ecoe
Jul 4 '16 at 14:09
add a comment |
Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to
+ scale_x_continuous(labels = scales::comma)
add a comment |
Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to
+ scale_x_continuous(labels = scales::comma)
add a comment |
Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to
+ scale_x_continuous(labels = scales::comma)
Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to
+ scale_x_continuous(labels = scales::comma)
edited Nov 15 '18 at 14:59
alessandra
52
52
answered Mar 16 '17 at 16:59
Derek CorcoranDerek Corcoran
1,69911225
1,69911225
add a comment |
add a comment |
As a more general solution, you can use scales::format_format
to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma
which only does comma separations of the orders of magnitude.
For example:
require(ggplot2)
require(scales)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# Here we define spaces as the big separator
point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)
# Plot it
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p + scale_x_continuous(labels = point)
add a comment |
As a more general solution, you can use scales::format_format
to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma
which only does comma separations of the orders of magnitude.
For example:
require(ggplot2)
require(scales)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# Here we define spaces as the big separator
point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)
# Plot it
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p + scale_x_continuous(labels = point)
add a comment |
As a more general solution, you can use scales::format_format
to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma
which only does comma separations of the orders of magnitude.
For example:
require(ggplot2)
require(scales)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# Here we define spaces as the big separator
point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)
# Plot it
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p + scale_x_continuous(labels = point)
As a more general solution, you can use scales::format_format
to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma
which only does comma separations of the orders of magnitude.
For example:
require(ggplot2)
require(scales)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# Here we define spaces as the big separator
point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)
# Plot it
p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p + scale_x_continuous(labels = point)
answered Nov 28 '17 at 17:34
user2739472user2739472
52858
52858
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%2f14563989%2fforce-r-to-stop-plotting-abbreviated-axis-labels-e-g-1e00-in-ggplot2%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