getting constant text size while using atop function in r
up vote
2
down vote
favorite
Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,
"layer1"
corresponds tocaption
entered by the user,
"layer2"
corresponds to results from a statistical test, and
"layer3"
corresponds to details about the statistical test carried out.
But when all three layers are included in the caption, it looks something like this-
library(ggplot2)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(substitute(
atop("layer1", "layer2")
)
, "layer3")))
Created on 2018-11-09 by the reprex package (v0.2.1)
So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.
Is there a way I can prevent this from happening?
r ggplot2 tidyverse plotmath
add a comment |
up vote
2
down vote
favorite
Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,
"layer1"
corresponds tocaption
entered by the user,
"layer2"
corresponds to results from a statistical test, and
"layer3"
corresponds to details about the statistical test carried out.
But when all three layers are included in the caption, it looks something like this-
library(ggplot2)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(substitute(
atop("layer1", "layer2")
)
, "layer3")))
Created on 2018-11-09 by the reprex package (v0.2.1)
So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.
Is there a way I can prevent this from happening?
r ggplot2 tidyverse plotmath
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,
"layer1"
corresponds tocaption
entered by the user,
"layer2"
corresponds to results from a statistical test, and
"layer3"
corresponds to details about the statistical test carried out.
But when all three layers are included in the caption, it looks something like this-
library(ggplot2)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(substitute(
atop("layer1", "layer2")
)
, "layer3")))
Created on 2018-11-09 by the reprex package (v0.2.1)
So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.
Is there a way I can prevent this from happening?
r ggplot2 tidyverse plotmath
Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,
"layer1"
corresponds tocaption
entered by the user,
"layer2"
corresponds to results from a statistical test, and
"layer3"
corresponds to details about the statistical test carried out.
But when all three layers are included in the caption, it looks something like this-
library(ggplot2)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(substitute(
atop("layer1", "layer2")
)
, "layer3")))
Created on 2018-11-09 by the reprex package (v0.2.1)
So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.
Is there a way I can prevent this from happening?
r ggplot2 tidyverse plotmath
r ggplot2 tidyverse plotmath
asked yesterday
Indrajeet Patil
1,241212
1,241212
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(
atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))
Cool. Wasn't aware ofdisplaystyle(x)
andtextstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was becauseplotmath
defaults toscriptstyle(x)
orscriptscriptstyle(x)
?
– Indrajeet Patil
17 hours ago
2
@IndrajeetPatil, I immediately tookdisplaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks liketextstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here isscriptstyle
, and if you added, say,atop
, it would bescriptscriptstyle
.
– Julius Vainora
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(
atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))
Cool. Wasn't aware ofdisplaystyle(x)
andtextstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was becauseplotmath
defaults toscriptstyle(x)
orscriptscriptstyle(x)
?
– Indrajeet Patil
17 hours ago
2
@IndrajeetPatil, I immediately tookdisplaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks liketextstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here isscriptstyle
, and if you added, say,atop
, it would bescriptscriptstyle
.
– Julius Vainora
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
add a comment |
up vote
2
down vote
accepted
I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(
atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))
Cool. Wasn't aware ofdisplaystyle(x)
andtextstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was becauseplotmath
defaults toscriptstyle(x)
orscriptscriptstyle(x)
?
– Indrajeet Patil
17 hours ago
2
@IndrajeetPatil, I immediately tookdisplaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks liketextstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here isscriptstyle
, and if you added, say,atop
, it would bescriptscriptstyle
.
– Julius Vainora
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(
atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))
I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(
atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))
answered 21 hours ago
Julius Vainora
26.1k75877
26.1k75877
Cool. Wasn't aware ofdisplaystyle(x)
andtextstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was becauseplotmath
defaults toscriptstyle(x)
orscriptscriptstyle(x)
?
– Indrajeet Patil
17 hours ago
2
@IndrajeetPatil, I immediately tookdisplaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks liketextstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here isscriptstyle
, and if you added, say,atop
, it would bescriptscriptstyle
.
– Julius Vainora
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
add a comment |
Cool. Wasn't aware ofdisplaystyle(x)
andtextstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was becauseplotmath
defaults toscriptstyle(x)
orscriptscriptstyle(x)
?
– Indrajeet Patil
17 hours ago
2
@IndrajeetPatil, I immediately tookdisplaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks liketextstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here isscriptstyle
, and if you added, say,atop
, it would bescriptscriptstyle
.
– Julius Vainora
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
Cool. Wasn't aware of
displaystyle(x)
and textstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath
defaults to scriptstyle(x)
or scriptscriptstyle(x)
?– Indrajeet Patil
17 hours ago
Cool. Wasn't aware of
displaystyle(x)
and textstyle(x)
functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath
defaults to scriptstyle(x)
or scriptscriptstyle(x)
?– Indrajeet Patil
17 hours ago
2
2
@IndrajeetPatil, I immediately took
displaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle
, and if you added, say, atop
, it would be scriptscriptstyle
.– Julius Vainora
16 hours ago
@IndrajeetPatil, I immediately took
displaystyle
just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle
is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle
, and if you added, say, atop
, it would be scriptscriptstyle
.– Julius Vainora
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
– Indrajeet Patil
16 hours ago
add a comment |
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
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235655%2fgetting-constant-text-size-while-using-atop-function-in-r%23new-answer', 'question_page');
}
);
Post as a guest
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
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
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