Hello! Hope you?re having a great day! I would like to combine plotting symbols with text. I have tried xp2a <- expression(paste(pch =3, ?my stuff?)) But when I use that as a plot title, it just shows as ?3 my stuff?. I have a feeling that it?s going to be something very straightforward that I am missing. Thanks for your help, Sincerely, Erin -- Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com [[alternative HTML version deleted]]
What is the result that you want?
If you cannot print the symbol that you want in a text format for this email,
can you give us the Unicode?
You can find that here: https://en.wikipedia.org/wiki/List_of_Unicode_characters
But you have to scroll down a bit to get the list.
Tim
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Erin Hodgess
Sent: Tuesday, June 7, 2022 3:39 PM
To: r-help at r-project.org
Subject: [R] Mixing plotting symbols with text
[External Email]
Hello!
Hope you?re having a great day!
I would like to combine plotting symbols with text.
I have tried
xp2a <- expression(paste(pch =3, ?my stuff?)) But when I use that as a plot
title, it just shows as ?3 my stuff?.
I have a feeling that it?s going to be something very straightforward that I am
missing.
Thanks for your help,
Sincerely,
Erin
--
Erin Hodgess, PhD
mailto: erinm.hodgess at gmail.com
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Ca24Bry9icNvM5nMbklTt79BL8XEZwCr23gdqmPhbctGT3LAmDHnbSQVZbTQzIsJ&s=6B6Z3cxtD3WY5Aj9Pn0JncHo45ujheBej5uQytJmwig&ePLEASE
do read the posting guide
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=Ca24Bry9icNvM5nMbklTt79BL8XEZwCr23gdqmPhbctGT3LAmDHnbSQVZbTQzIsJ&s=nxJBNhFueZylG4iHMRAjipCAASj2UFNzde6qi7tM7Bk&eand
provide commented, minimal, self-contained, reproducible code.
I assume this is using R's basic plotting engine.
If so, you **might** be able to do this nicely with legend(). Jim Lemon's
plotrix package might also have something for you.
Otherwise you can set plot limits explicitly, and then plot the point
outside those limits with your desired pch by setting xpd = TRUE. Something
like:
plot(c(1,1.5,2), c(3,5.5,4), pch = c(1,3,1), ylim = c(2.5,4.5),
xpd = TRUE)
Then use mtext() to add your text nearby.
Inelegant, but it should work.
Cheers,
Bert Gunter
On Tue, Jun 7, 2022 at 12:39 PM Erin Hodgess <erinm.hodgess at gmail.com>
wrote:
> Hello!
>
> Hope you?re having a great day!
>
> I would like to combine plotting symbols with text.
>
> I have tried
> xp2a <- expression(paste(pch =3, ?my stuff?))
> But when I use that as a plot title, it just shows as ?3 my stuff?.
>
> I have a feeling that it?s going to be something very straightforward that
> I am missing.
>
> Thanks for your help,
> Sincerely,
> Erin
> --
> Erin Hodgess, PhD
> mailto: erinm.hodgess at gmail.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
Thank you everyone, for your help!! Sincerely, Erin On Tue, Jun 7, 2022 at 4:13 PM Bert Gunter <bgunter.4567 at gmail.com> wrote:> I assume this is using R's basic plotting engine. > > If so, you **might** be able to do this nicely with legend(). Jim Lemon's > plotrix package might also have something for you. > > Otherwise you can set plot limits explicitly, and then plot the point > outside those limits with your desired pch by setting xpd = TRUE. Something > like: > > plot(c(1,1.5,2), c(3,5.5,4), pch = c(1,3,1), ylim = c(2.5,4.5), > xpd = TRUE) > > Then use mtext() to add your text nearby. > Inelegant, but it should work. > > Cheers, > Bert Gunter > > > On Tue, Jun 7, 2022 at 12:39 PM Erin Hodgess <erinm.hodgess at gmail.com> > wrote: > >> Hello! >> >> Hope you?re having a great day! >> >> I would like to combine plotting symbols with text. >> >> I have tried >> xp2a <- expression(paste(pch =3, ?my stuff?)) >> But when I use that as a plot title, it just shows as ?3 my stuff?. >> >> I have a feeling that it?s going to be something very straightforward that >> I am missing. >> >> Thanks for your help, >> Sincerely, >> Erin >> -- >> Erin Hodgess, PhD >> mailto: erinm.hodgess at gmail.com >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html > > >> and provide commented, minimal, self-contained, reproducible code. >> > --Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com [[alternative HTML version deleted]]
Hi Erin,
Here's a kinda clunky way to get your plot title. It can be modified
to do fancier things like intersperse symbols with letters but you may
need no more than this. Have fun.
par(mar=c(5,4,5,2))
plot(0,xlim=c(-1,1),ylim=c(-1,1),type="n",xlab="Nonsense",ylab="Intensity")
points(runif(4,-1,1),runif(4,-1,1),pch=3)
points(runif(4,-1,1),runif(4,-1,1),pch=4)
symbol_n_text<-function(x,y,pch,txt,adj=0,cex=1) {
oldcex<-par(cex=cex)
x<-x-(strwidth("M ")+strwidth(txt))/2
points(x,y,pch=pch)
x<-x+strwidth("M ")
text(x,y,txt,adj=adj)
par(oldcex)
}
par(xpd=TRUE)
symbol_n_text(0,1.35,3,"your stuff",cex=1.5)
symbol_n_text(0,1.2,4,"my stuff",cex=1.5)
Thanks for the nod, Bert.
Jim
On Wed, Jun 8, 2022 at 5:39 AM Erin Hodgess <erinm.hodgess at gmail.com>
wrote:>
> Hello!
>
> Hope you?re having a great day!
>
> I would like to combine plotting symbols with text.
>
> I have tried
> xp2a <- expression(paste(pch =3, ?my stuff?))
> But when I use that as a plot title, it just shows as ?3 my stuff?.
>
> I have a feeling that it?s going to be something very straightforward that
> I am missing.
>
> Thanks for your help,
> Sincerely,
> Erin
> --
> Erin Hodgess, PhD
> mailto: erinm.hodgess at gmail.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.