Plotmath issue superscript "-"

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Plotmath issue superscript "-"

Gavin Simpson
Dear List,

I'm trying to typeset some chemical ions in axis labels. These have both
super and subscript components, and for some, I need a superscript "-".
In LaTeX I might use $NO_3^-$ to do the typesetting, but I'm having a
problem getting the correct invocation for expression:

> expression(NO^{-}[3])
Error: syntax error, unexpected '}' in "expression(NO^{-}"
> expression(NO^-[3])
Error: syntax error, unexpected '[' in "expression(NO^-["
> expression(NO^-)
Error: syntax error, unexpected ')' in "expression(NO^-)"
> expression(NO^{-})
Error: syntax error, unexpected '}' in "expression(NO^{-}"

This is with R 2.5.1 (exact version info below).

I suspect this is something to do with my use of the "-", which has some
special meaning.

Is there a way to achieve a superscript "-" (or similar looking
character) using the plotmath routines in R?

Thanks in advance,

G

> version
               _                                          
platform       i686-pc-linux-gnu                          
arch           i686                                      
os             linux-gnu                                  
system         i686, linux-gnu                            
status         Patched                                    
major          2                                          
minor          5.1                                        
year           2007                                      
month          07                                        
day            05                                        
svn rev        42131                                      
language       R                                          
version.string R version 2.5.1 Patched (2007-07-05 r42131)

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotmath issue superscript "-"

Scionforbai
Try:

  plot(0,0,"n")
  text(0,0,expression( {NO[3]}^'-'))

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotmath issue superscript "-"

Peter Dalgaard
In reply to this post by Gavin Simpson
Gavin Simpson wrote:

> Dear List,
>
> I'm trying to typeset some chemical ions in axis labels. These have both
> super and subscript components, and for some, I need a superscript "-".
> In LaTeX I might use $NO_3^-$ to do the typesetting, but I'm having a
> problem getting the correct invocation for expression:
>
>  
>> expression(NO^{-}[3])
>>    
> Error: syntax error, unexpected '}' in "expression(NO^{-}"
>  
>> expression(NO^-[3])
>>    
> Error: syntax error, unexpected '[' in "expression(NO^-["
>  
>> expression(NO^-)
>>    
> Error: syntax error, unexpected ')' in "expression(NO^-)"
>  
>> expression(NO^{-})
>>    
> Error: syntax error, unexpected '}' in "expression(NO^{-}"
>
> This is with R 2.5.1 (exact version info below).
>
> I suspect this is something to do with my use of the "-", which has some
> special meaning.
>
> Is there a way to achieve a superscript "-" (or similar looking
> character) using the plotmath routines in R?
>
>  
It's an operator, it needs something to operate on.

Try

 plot(0,main=quote(NO^-{}))



> Thanks in advance,
>
> G
>
>  
>> version
>>    
>                _                                          
> platform       i686-pc-linux-gnu                          
> arch           i686                                      
> os             linux-gnu                                  
> system         i686, linux-gnu                            
> status         Patched                                    
> major          2                                          
> minor          5.1                                        
> year           2007                                      
> month          07                                        
> day            05                                        
> svn rev        42131                                      
> language       R                                          
> version.string R version 2.5.1 Patched (2007-07-05 r42131)
>
>  


--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([hidden email])                  FAX: (+45) 35327907

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotmath issue superscript "-"

P Ehlers
If you need a subscript as well, I like

  plot(0, main=quote({NO^'\x96'}[3]))

Peter Ehlers

Peter Dalgaard wrote:

> Gavin Simpson wrote:
>> Dear List,
>>
>> I'm trying to typeset some chemical ions in axis labels. These have both
>> super and subscript components, and for some, I need a superscript "-".
>> In LaTeX I might use $NO_3^-$ to do the typesetting, but I'm having a
>> problem getting the correct invocation for expression:
>>
>>  
>>> expression(NO^{-}[3])
>>>    
>> Error: syntax error, unexpected '}' in "expression(NO^{-}"
>>  
>>> expression(NO^-[3])
>>>    
>> Error: syntax error, unexpected '[' in "expression(NO^-["
>>  
>>> expression(NO^-)
>>>    
>> Error: syntax error, unexpected ')' in "expression(NO^-)"
>>  
>>> expression(NO^{-})
>>>    
>> Error: syntax error, unexpected '}' in "expression(NO^{-}"
>>
>> This is with R 2.5.1 (exact version info below).
>>
>> I suspect this is something to do with my use of the "-", which has some
>> special meaning.
>>
>> Is there a way to achieve a superscript "-" (or similar looking
>> character) using the plotmath routines in R?
>>
>>  
> It's an operator, it needs something to operate on.
>
> Try
>
>  plot(0,main=quote(NO^-{}))
>
>
>
>> Thanks in advance,
>>
>> G
>>
>>  
>>> version
>>>    
>>                _                                          
>> platform       i686-pc-linux-gnu                          
>> arch           i686                                      
>> os             linux-gnu                                  
>> system         i686, linux-gnu                            
>> status         Patched                                    
>> major          2                                          
>> minor          5.1                                        
>> year           2007                                      
>> month          07                                        
>> day            05                                        
>> svn rev        42131                                      
>> language       R                                          
>> version.string R version 2.5.1 Patched (2007-07-05 r42131)
>>
>>  
>
>

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotmath issue superscript "-"

Scionforbai
Hallo,

> If you need a subscript as well, I like
>
>   plot(0, main=quote({NO^'\x96'}[3]))


I tried this but I get:

>  plot(0, main=quote({NO^'\x96'}[3]))
Errore in title(...) : stringa multibyte non valida ('invalid multibyte string')

My R version is:
platform       i686-redhat-linux-gnu
version.string R version 2.4.1 (2006-12-18)

locale is: LANG=it_IT.UTF-8

What is this multibyte string? Does it depend on LOCALE settings?
Where can I find further docs on this way to pass character
descriptors?
Thanks,
ScionForbai

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotmath issue superscript "-"

P Ehlers
Yes, sorry, I should have said that I was on Windows.
In a UTF-8 locale, you could try \u2013 in place of \x96.
The character is an endash.

Peter Ehlers

Scionforbai wrote:

> Hallo,
>
>> If you need a subscript as well, I like
>>
>>   plot(0, main=quote({NO^'\x96'}[3]))
>
>
> I tried this but I get:
>
>>  plot(0, main=quote({NO^'\x96'}[3]))
> Errore in title(...) : stringa multibyte non valida ('invalid multibyte string')
>
> My R version is:
> platform       i686-redhat-linux-gnu
> version.string R version 2.4.1 (2006-12-18)
>
> locale is: LANG=it_IT.UTF-8
>
> What is this multibyte string? Does it depend on LOCALE settings?
> Where can I find further docs on this way to pass character
> descriptors?
> Thanks,
> ScionForbai
>
>

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotmath issue superscript "-"

Gavin Simpson
In reply to this post by Peter Dalgaard
On Thu, 2007-09-20 at 18:19 +0200, Peter Dalgaard wrote:
> Gavin Simpson wrote:
> > Dear List,
> >
> > I'm trying to typeset some chemical ions in axis labels. These have both
> > super and subscript components, and for some, I need a superscript "-".
> > In LaTeX I might use $NO_3^-$ to do the typesetting, but I'm having a
> > problem getting the correct invocation for expression:
<snip />
> >  
> It's an operator, it needs something to operate on.
>
> Try
>
>  plot(0,main=quote(NO^-{}))
>

Thanks, Peter, for this solution, and also to Peter Ehlers and
ScionForbai for theirs.

All the best,

G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
[hidden email] mailing list
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.