Skip to content

problem with symbol function

17 messages · Andrew Dolman, Duncan Murdoch, Joshua Wiley +2 more

#
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 ----
#
it just plot solid lines? I also have a similar problem on my PC at  
the office, which run XP pro...


Le 27 avr. 09 ? 22:29, Joshua Wiley a ?crit :
--
Christophe Dutang
Ph. D. student at ISFA, Lyon, France
website: http://dutangc.free.fr
#
what is your service pack version?

at home I use the SP2 version.

Le 27 avr. 09 ? 22:29, Joshua Wiley a ?crit :
--
Christophe Dutang
Ph. D. student at ISFA, Lyon, France
website: http://dutangc.free.fr
#
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 ----
#
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 :
--
Christophe Dutang
Ph. D. student at ISFA, Lyon, France
website: http://dutangc.free.fr
#
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 ----
#
On 27/04/2009 4:29 PM, Joshua Wiley wrote:
Were you using the same code as Christophe?  I see what he saw: the 
circle comes out with a solid line.

Duncan Murdoch
#
On 27/04/2009 5:23 PM, Christophe Dutang wrote:
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
#
My apologies; I did not use exactly his code. I usually plot directly to postscript files. Since when I manipulated the lty argument, I got the expected results (via postscript), everything seemed in order. It never occurred to me that postscript would not give me the same view. I am very sorry for the inconvenience.


Joshua Wiley



---- Original message ----
#
ok, I'll try to use to your code or use pdf files.

Thanks for all

Christophe

Le 28 avr. 09 ? 01:38, Joshua Wiley a ?crit :
--
Christophe Dutang
Ph. D. student at ISFA, Lyon, France
website: http://dutangc.free.fr
#
The my.symbols function in the TeachingDemos package works here.  It was designed to work like symbols, but with user defined symbols:

library(TeachingDemos)

theta <- seq(0, 2*pi, len=256)
circ <- cbind( cos(theta), sin(theta) )

x <- runif(10)
y <- rnorm(10, 100, 20)
z <- runif(10, .5, 1)

my.symbols(x,y, circ, inches=.3, add=FALSE)
my.symbols(x,y, circ, inches=.3, lty='dashed', add=FALSE)
my.symbols(x,y, circ, inches=.5*z, lty='dashed', add=FALSE)
#
Based on your solution, could we not fix this issue for the symbol  
function?

Le 27 avr. 09 ? 23:47, Duncan Murdoch a ?crit :
--
Christophe Dutang
Ph. D. student at ISFA, Lyon, France
website: http://dutangc.free.fr
#
Christophe Dutang wrote:
Sure, send a patch.

Duncan Murdoch