[R-SIG-Mac] image() to Rplot.pdf

Angel Berihuete Macías angel at alfomega.es
Thu Jun 19 00:52:41 CEST 2008


I work with three functions.

1) CreaPaleta64(), creates my color palette.
2) normalize(), standardize dataset (usually matrix)
3) Spec2D.Draw(), which plot the image.

Ok, let's do it

 >Colors= CreaPaleta64(64)
 >X=matrix(1:120*50,nrow=120,ncol=50)
 >Spec2D.Draw(X,Colors)

Now I have a quarzt() device, but when I "save as" Rplot.pdf the gray  
lines appear over the image.

Thanks


%%%%%%%%%%%%%%%%%%%

CreaPaleta <- function(n=64) {
  C <-c(
      0.0417,         0,        0,
      0.0833,         0,        0,
      0.1250,         0,        0,
      0.1667,         0,        0,
      0.2083,         0,        0,
      0.2500,         0,        0,
      0.2917,         0,        0,
      0.3333,         0,        0,
      0.3750,         0,        0,
      0.4167,         0,        0,
      0.4583,         0,        0,
      0.5000,         0,        0,
      0.5417,         0,        0,
      0.5833,         0,        0,
      0.6250,         0,        0,
      0.6667,         0,        0,
      0.7083,         0,        0,
      0.7500,         0,        0,
      0.7917,         0,        0,
      0.8333,         0,        0,
      0.8750,         0,        0,
      0.9167,         0,        0,
      0.9583,         0,        0,
      1.0000,         0,        0,
      1.0000,    0.0417,        0,
      1.0000,    0.0833,        0,
      1.0000,    0.1250,        0,
      1.0000,    0.1667,        0,
      1.0000,    0.2083,        0,
      1.0000,    0.2500,        0,
      1.0000,    0.2917,        0,
      1.0000,    0.3333,        0,
      1.0000,    0.3750,        0,
      1.0000,    0.4167,        0,
      1.0000,    0.4583,        0,
      1.0000,    0.5000,        0,
      1.0000,    0.5417,        0,
      1.0000,    0.5833,        0,
      1.0000,    0.6250,        0,
      1.0000,    0.6667,        0,
      1.0000,    0.7083,        0,
      1.0000,    0.7500,        0,
      1.0000,    0.7917,        0,
      1.0000,    0.8333,        0,
      1.0000,    0.8750,        0,
      1.0000,    0.9167,        0,
      1.0000,    0.9583,        0,
      1.0000,    1.0000,        0,
      1.0000,    1.0000,   0.0625,
      1.0000,    1.0000,   0.1250,
      1.0000,    1.0000,   0.1875,
      1.0000,    1.0000,   0.2500,
      1.0000,    1.0000,   0.3125,
      1.0000,    1.0000,   0.3750,
      1.0000,    1.0000,   0.4375,
      1.0000,    1.0000,   0.5000,
      1.0000,    1.0000,   0.5625,
      1.0000,    1.0000,   0.6250,
      1.0000,    1.0000,   0.6875,
      1.0000,    1.0000,   0.7500,
      1.0000,    1.0000,   0.8125,
      1.0000,    1.0000,   0.8750,
      1.0000,    1.0000,   0.9375,
      1.0000,    1.0000,   1.0000 )

  C <- matrix(C, nrow = 64, ncol = 3, byrow = TRUE)

   Chex <- rgb(C[,1], C[,2], C[,3])
  paleta  <- palette( Chex )

  Chex <- rgb(C[,1], C[,2], C[,3])
  paleta  <- palette( Chex )

  if( n == 32 )  { return(paleta[seq(1,64,2)]) }
  if( n == 16 )  { return(paleta[seq(1,64,4)]) }
  if( n == 8 )   { return(paleta[seq(1,64,8)]) }
return(paleta)
} # -- Andres Jimenez 2008-jun -------------------------------------

normalize <- function(img) {

(img-min(img))/(max(img)-min(img))

}  
#-----------------------------------------------------------------------------

Spec2D.Draw <- function(S, Colores, labx="", laby="") {
     image((1:nrow(S)), (1:ncol(S)), normalize(S),
            col=Colores, axes = FALSE, xlab=labx, ylab=laby)
} # -- Andres Jimenez 2008 -jun---------------------------------------



%%%%%%%%%%%%%%%%%%%%%%%%%%%%



El 18/06/2008, a las 23:48, Simon Urbanek escribió:

>
> On Jun 18, 2008, at 5:21 PM, Angel Berihuete Macías wrote:
>
>> Thank you very much,  Simon!
>>
>> I zoom in the image, but no changes. There are lines, ugly gray  
>> lines. Next, I open the image with Acrobat Reader and again no  
>> changes.
>>
>
> Can you tell me exactly how you create the PDF?
>
> Thanks,
> Simon
>
>
>> Any help will be wellcome.
>>
>> Ángel Berihuete.
>>
>> El 18/06/2008, a las 17:26, Simon Urbanek escribió:
>>
>>>
>>> On Jun 18, 2008, at 2:49 AM, Angel Berihuete Macías wrote:
>>>
>>>> Hello all members!
>>>>
>>>> I work with version 2.7.1 RC (2008-06-15 r45927). When I save as  
>>>> Rplot.pdf a quartz() device generated with image() function,  
>>>> still appears gray rectangles over the image ( the image in the  
>>>> quartz() device is all right! )
>>>>
>>>
>>> That is a rendering issue in Preview (zoom in and you'll see that  
>>> there are no lines), it is unrelated to the Quartz device. The PDF  
>>> itself is fine, but Preview doesn't correct for anti-aliasing  
>>> effects. I think using Acrobat may work (I don't want to install  
>>> it since it messes up the system so I cannot check).
>>>
>>> Cheers,
>>> Simon
>>>
>>>
>>
>>
>



More information about the R-SIG-Mac mailing list