Discussion:
ggplot2 super and subscript
Theodore Kapellos
2018-08-22 19:32:44 UTC
Permalink
Hi all,

I m trying to write the following text on an axis on a ggplot2 graph and I
can t make it work. Worse, any advice in blogs I found, is not explained
and therefore I can t
work out how the successful solutions to other users work. Can someone help
and provide a documentation of the symbols they use? Here is what I want to
type, the "+"
in superscript:


"Percentage of CD45+ cells"

Thanks,
Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brandon Hurr
2018-08-22 20:45:53 UTC
Permalink
Follow along here. One way is bquote but I’ve preferred to use the
expressions like in the second answer.
https://stackoverflow.com/questions/37825558/how-to-use-superscript-with-ggplot2

HTH
b
Post by Theodore Kapellos
Hi all,
I m trying to write the following text on an axis on a ggplot2 graph and
I can t make it work. Worse, any advice in blogs I found, is not explained
and therefore I can t
work out how the successful solutions to other users work. Can someone
help and provide a documentation of the symbols they use? Here is what I
want to type, the "+"
"Percentage of CD45+ cells"
Thanks,
Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
m***@gmail.com
2018-08-22 20:50:02 UTC
Permalink
labs(x = "Your x axis label", y= as.expression(bquote(~"Percentage of"~"CD45"^{"+"}~"Cells" )) )







From: ***@googlegroups.com <***@googlegroups.com> On Behalf Of Brandon Hurr
Sent: Wednesday, August 22, 2018 10:46 PM
To: Theodore Kapellos <***@gmail.com>
Cc: ggplot2 <***@googlegroups.com>
Subject: Re: ggplot2 super and subscript



Follow along here. One way is bquote but I’ve preferred to use the expressions like in the second answer.

https://stackoverflow.com/questions/37825558/how-to-use-superscript-with-ggplot2



HTH

b



On Wed, Aug 22, 2018 at 12:36 Theodore Kapellos <***@gmail.com <mailto:***@gmail.com> > wrote:

Hi all,



I m trying to write the following text on an axis on a ggplot2 graph and I can t make it work. Worse, any advice in blogs I found, is not explained and therefore I can t

work out how the successful solutions to other users work. Can someone help and provide a documentation of the symbols they use? Here is what I want to type, the "+"

in superscript:



"Percentage of CD45+ cells"



Thanks,

Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com <mailto:***@googlegroups.com>
To unsubscribe: email ggplot2+***@googlegroups.com <mailto:ggplot2%***@googlegroups.com>
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com <mailto:ggplot2+***@googlegroups.com> .
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com <mailto:***@googlegroups.com>
To unsubscribe: email ggplot2+***@googlegroups.com <mailto:ggplot2+***@googlegroups.com>
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com <mailto:ggplot2+***@googlegroups.com> .
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Theodore Kapellos
2018-08-23 07:04:37 UTC
Permalink
Euxaristw Marie! " " gia keimeno, ~ gia sindesi keimenwn kai { } gia ti
akrivws?
Post by m***@gmail.com
labs(x = "Your x axis label", y= as.expression(bquote(~"Percentage
of"~"CD45"^{"+"}~"Cells" )) )
<javascript:>> *On Behalf Of *Brandon Hurr
*Sent:* Wednesday, August 22, 2018 10:46 PM
*Subject:* Re: ggplot2 super and subscript
Follow along here. One way is bquote but I’ve preferred to use the
expressions like in the second answer.
https://stackoverflow.com/questions/37825558/how-to-use-superscript-with-ggplot2
HTH
b
Hi all,
I m trying to write the following text on an axis on a ggplot2 graph and
I can t make it work. Worse, any advice in blogs I found, is not explained
and therefore I can t
work out how the successful solutions to other users work. Can someone
help and provide a documentation of the symbols they use? Here is what I
want to type, the "+"
"Percentage of CD45+ cells"
Thanks,
Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Theodore Kapellos
2018-08-23 07:02:54 UTC
Permalink
Thanks Brandon. So to understand, " " is for normal text, ~ connects text
and { } is used for what exactly?
Post by Brandon Hurr
Follow along here. One way is bquote but I’ve preferred to use the
expressions like in the second answer.
https://stackoverflow.com/questions/37825558/how-to-use-superscript-with-ggplot2
HTH
b
Post by Theodore Kapellos
Hi all,
I m trying to write the following text on an axis on a ggplot2 graph and
I can t make it work. Worse, any advice in blogs I found, is not explained
and therefore I can t
work out how the successful solutions to other users work. Can someone
help and provide a documentation of the symbols they use? Here is what I
want to type, the "+"
"Percentage of CD45+ cells"
Thanks,
Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups
"ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Zack Weinberg
2018-08-23 13:08:28 UTC
Permalink
The documentation you're looking for is ?plotmath in an interactive R
session, or https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/plotmath.html
.

It doesn't actually document the effect of `a ~ b`, only `a ~~ b`, but
I believe you are correct that `a ~ b` draws a and b with a normal
space between (`a ~~ b` is described as drawing a and b with *extra*
space between).

{ } are "invisible grouping". The example given is `x^{y + z}` places
the entire expression `y + z` in the superscript of x. I get the same
result with
"Percentage of"~"CD45"^{"+"}~"Cells" as with "Percentage
of"~"CD45"^"+"~"Cells", so perhaps Marios is just in the habit of
always writing ^{...} whether or not the curly braces are necessary.

zw

On Thu, Aug 23, 2018 at 3:02 AM, Theodore Kapellos
Post by Theodore Kapellos
Thanks Brandon. So to understand, " " is for normal text, ~ connects text
and { } is used for what exactly?
Follow along here. One way is bquote but I’ve preferred to use the
expressions like in the second answer.
https://stackoverflow.com/questions/37825558/how-to-use-superscript-with-ggplot2
HTH
b
Post by Theodore Kapellos
Hi all,
I m trying to write the following text on an axis on a ggplot2 graph and
I can t make it work. Worse, any advice in blogs I found, is not explained
and therefore I can t
work out how the successful solutions to other users work. Can someone
help and provide a documentation of the symbols they use? Here is what I
want to type, the "+"
"Percentage of CD45+ cells"
Thanks,
Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups
"ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marios Barlas
2018-08-23 13:09:54 UTC
Permalink
~ is used to replace the character for space.

I had a similar issue recently :)

M.
Post by Zack Weinberg
The documentation you're looking for is ?plotmath in an interactive R
session, or https://stat.ethz.ch/R-manual/R-devel/library/grDevices/
html/plotmath.html
.
It doesn't actually document the effect of `a ~ b`, only `a ~~ b`, but
I believe you are correct that `a ~ b` draws a and b with a normal
space between (`a ~~ b` is described as drawing a and b with *extra*
space between).
{ } are "invisible grouping". The example given is `x^{y + z}` places
the entire expression `y + z` in the superscript of x. I get the same
result with
"Percentage of"~"CD45"^{"+"}~"Cells" as with "Percentage
of"~"CD45"^"+"~"Cells", so perhaps Marios is just in the habit of
always writing ^{...} whether or not the curly braces are necessary.
zw
On Thu, Aug 23, 2018 at 3:02 AM, Theodore Kapellos
Post by Theodore Kapellos
Thanks Brandon. So to understand, " " is for normal text, ~ connects text
and { } is used for what exactly?
Post by Brandon Hurr
Follow along here. One way is bquote but I’ve preferred to use the
expressions like in the second answer.
https://stackoverflow.com/questions/37825558/how-to-use-
superscript-with-ggplot2
Post by Theodore Kapellos
Post by Brandon Hurr
HTH
b
Post by Theodore Kapellos
Hi all,
I m trying to write the following text on an axis on a ggplot2 graph
and
Post by Theodore Kapellos
Post by Brandon Hurr
Post by Theodore Kapellos
I can t make it work. Worse, any advice in blogs I found, is not
explained
Post by Theodore Kapellos
Post by Brandon Hurr
Post by Theodore Kapellos
and therefore I can t
work out how the successful solutions to other users work. Can someone
help and provide a documentation of the symbols they use? Here is what
I
Post by Theodore Kapellos
Post by Brandon Hurr
Post by Theodore Kapellos
want to type, the "+"
"Percentage of CD45+ cells"
Thanks,
Theo
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google
Groups
Post by Theodore Kapellos
Post by Brandon Hurr
Post by Theodore Kapellos
"ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Theodore Kapellos
Post by Brandon Hurr
Post by Theodore Kapellos
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2
mailing
Post by Theodore Kapellos
list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups
"ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/
devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...