[R] problem with symbol function

Duncan Murdoch murdoch at stats.uwo.ca
Wed Apr 29 12:17:30 CEST 2009


Christophe Dutang wrote:
> Based on your solution, could we not fix this issue for the symbol  
> function?
>   

Sure, send a patch.

Duncan Murdoch
> Le 27 avr. 09 à 23:47, Duncan Murdoch a écrit :
>
>   
>> On 27/04/2009 5:23 PM, Christophe Dutang wrote:
>>     
>>> so it could be a limitation of graphics on windows?
>>>       
>> It's not graphics on Windows, but it appears to be a limitation of  
>> the windows() graphics device in R.  It is used for bitmap plots as  
>> well as on-screen plots, which is why you saw the same effect in  
>> jpeg, but different devices are used for Postscript and PDF.
>>
>> When drawing lines, R handles the dash style itself, rather than  
>> using the built-in dashes.  But it doesn't do so for circles, and  
>> doesn't make use of the Windows line styles.
>>
>> If you really need the dashes onscreen, you can draw the circle  
>> yourself.  Assuming the scales are equal on both axes that's easy,  
>> just use
>>
>>     
>>> theta <- seq(0,2*pi, len=256)
>>> lines(x+r*cos(theta), y+r*sin(theta), lty="dashed")
>>>       
>> (where (x,y) is the center and r is the radius).  It's more work if  
>> you want things to appear as circles when the scales are unequal,  
>> but I think this works:
>>
>> circle <- function(x, y, inches=1, ...) {
>>  theta <- seq(0, 2*pi, len=256)
>>  lines(x + grconvertX(inches*cos(theta), "inches", "user") -  
>> grconvertX(0, "inches", "user"),
>>        y + grconvertY(inches*sin(theta), "inches", "user") -
>> grconvertY(0, "inches", "user"),
>>        ...)
>> }
>>
>> so you'd get the plot you wanted using
>>
>> circle(0, 0, inches = 1.5, fg="black",lty="dashed")
>>
>> The circle function is not vectorized, so it's not as useful as  
>> symbols, but it could be improved.
>>
>> Duncan Murdoch
>>
>>
>>     
>>> It also appears with "long dash" lines.
>>> x <- -4:4
>>> y <- -4:4
>>> plot(x,y,type="n")
>>> symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black",   
>>> lty="solid")
>>> symbols(0, 0, add = TRUE, circles = 1, inches = 2,   
>>> fg="black",lty="dashed")
>>> symbols(0, 0, add = TRUE, circles = 1, inches = 3,   
>>> fg="black",lty="longdash", lwd=2)
>>> Le 27 avr. 09 à 23:07, Joshua Wiley a écrit :
>>>       
>>>> I read that the lty=2 argument does not work on all graphics   
>>>> devices. You might double check that since it works on mac.
>>>>
>>>>
>>>> Joshua Wiley
>>>>
>>>>
>>>>
>>>> ---- Original message ----
>>>>         
>>>>> Date: Mon, 27 Apr 2009 22:58:11 +0200
>>>>> From: Christophe Dutang <dutangc at gmail.com>
>>>>> Subject: Re: [R] problem with symbol function
>>>>> To: Joshua Wiley <jwile004 at ucr.edu>
>>>>> Cc: r-help at r-project.org
>>>>>
>>>>> This point is ok if I download R from the Austrian mirror. R is
>>>>> properly install on both computers. I also get this strange  
>>>>> behavior
>>>>> with R 2.7.2. There is something I'm missing...
>>>>>
>>>>>
>>>>> Le 27 avr. 09 à 22:54, Joshua Wiley a écrit :
>>>>>
>>>>>           
>>>>>> I am running SP3. You said earlier that you were having trouble
>>>>>> downloading 2.9.0, are you sure everything downloaded and  
>>>>>> installed
>>>>>> properly? There have been some questions about transitioning to  
>>>>>> the
>>>>>> new build going around.
>>>>>>
>>>>>> Joshua Wiley
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---- Original message ----
>>>>>>             
>>>>>>> Date: Mon, 27 Apr 2009 22:45:26 +0200
>>>>>>> From: Christophe Dutang <dutangc at gmail.com>
>>>>>>> Subject: Re: [R] problem with symbol function
>>>>>>> To: Joshua Wiley <jwile004 at ucr.edu>
>>>>>>> Cc: r-help at r-project.org
>>>>>>>
>>>>>>> what is your service pack version?
>>>>>>>
>>>>>>> at home I use the SP2 version.
>>>>>>>
>>>>>>> Le 27 avr. 09 à 22:29, Joshua Wiley a écrit :
>>>>>>>
>>>>>>>               
>>>>>>>> Hi Christophe,
>>>>>>>>
>>>>>>>> I am able to plot dashed circles on Windows. I'm afraid I do not
>>>>>>>> have any suggestions for you. What happens when you try to  
>>>>>>>> plot it
>>>>>>>> on Windows?
>>>>>>>>
>>>>>>>>
>>>>>>>> Joshua Wiley
>>>>>>>>
>>>>>>>>
>>>>>>>> ---- Original message ----
>>>>>>>>                 
>>>>>>>>> Date: Mon, 27 Apr 2009 22:15:53 +0200
>>>>>>>>> From: r-help-bounces at r-project.org (on behalf of Christophe
>>>>>>>>> Dutang <dutangc at gmail.com
>>>>>>>>>                   
>>>>>>>>>> )
>>>>>>>>>>                     
>>>>>>>>> Subject: [R] problem with symbol function
>>>>>>>>> To: r-help at r-project.org
>>>>>>>>>
>>>>>>>>> Hi all,
>>>>>>>>>
>>>>>>>>> I use the symbol functions to draw circles. But the argument  
>>>>>>>>> lty
>>>>>>>>> does
>>>>>>>>> not work on windows but works correctly on my macbook:
>>>>>>>>>
>>>>>>>>> x <- -4:4
>>>>>>>>> y <- -4:4
>>>>>>>>>
>>>>>>>>> plot(x,y,type="n")
>>>>>>>>>
>>>>>>>>> symbols(0, 0, add = TRUE, circles = 1, inches = 1, fg="black",
>>>>>>>>> lty="solid")
>>>>>>>>>
>>>>>>>>> symbols(0, 0, add = TRUE, circles = 1, inches = 2, fg="black",
>>>>>>>>> lty="dashed")
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The second circle should be drawn with dash... it works on my
>>>>>>>>> macbook
>>>>>>>>> but on my PC.
>>>>>>>>>
>>>>>>>>> I use R 2.9.0 on windows xp home and mac os 10.5.
>>>>>>>>>
>>>>>>>>> Does anyone have this problem? is it a limitation of windows?
>>>>>>>>>
>>>>>>>>> thanks in advance
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Christophe
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Christophe Dutang
>>>>>>>>> Ph. D. student at ISFA, Lyon, France
>>>>>>>>> website: http://dutangc.free.fr
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 	[[alternative HTML version deleted]]
>>>>>>>>>
>>>>>>>>> ______________________________________________
>>>>>>>>> R-help at r-project.org 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.
>>>>>>>>>                   
>>>>>>> --
>>>>>>> Christophe Dutang
>>>>>>> Ph. D. student at ISFA, Lyon, France
>>>>>>> website: http://dutangc.free.fr
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> --
>>>>> Christophe Dutang
>>>>> Ph. D. student at ISFA, Lyon, France
>>>>> website: http://dutangc.free.fr
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>> --
>>> Christophe Dutang
>>> Ph. D. student at ISFA, Lyon, France
>>> website: http://dutangc.free.fr
>>> 	[[alternative HTML version deleted]]
>>> ------------------------------------------------------------------------
>>> ______________________________________________
>>> R-help at r-project.org 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.
>>>       
>
> --
> Christophe Dutang
> Ph. D. student at ISFA, Lyon, France
> website: http://dutangc.free.fr
>
>
>
>
>




More information about the R-help mailing list