Hi Luis,

Following David's suggestion, it worked for me:

pdf('exp.pdf',colormodel='grey')  # Note the change here :)
barplot(table(subset(iris,Petal.Width>1)$Species))
dev.off()

Here is my session info:
> sessionInfo()
R version 2.8.1 Patched (2009-01-01 r47434)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


HTH,

Jorge


On Fri, Jan 23, 2009 at 11:17 PM, David Winsemius <dwinsem...@comcast.net>wrote:

> Try changing the color to "grey".
>
> Despite the help pages saying this:
> colormodel
> a character string describing the color model: currently allowed values are
> "rgb", "gray" and "cmyk". Defaults to "rgb".
>
> I got the expected behavior by making the "gray" -> "grey" change on my Mac
> OS 10.5.6/R2.8.1 system.
>
> --
> David Winsemius
>
> On Jan 23, 2009, at 7:21 PM, Luis Torgo wrote:
>
>  I'm trying to create figures in PDF that use the 'gray' colormodel instead
>> of the default 'RGB' model, by requirements of a publisher.
>>
>> My problem has to do with the fact that I'm not being able to get gray
>> colors with this option on the pdf() driver. Here is a small example for
>> problem replication:
>>
>> > R.version
>>             _                          platform       i486-pc-linux-gnu
>>        arch           i486                       os             linux-gnu
>>                system         i486, linux-gnu            status
>>                        major          2                          minor
>>    8.1                        year           2008
>> month          12                         day            22
>>         svn rev        47281                      language       R
>>                version.string R version 2.8.1 (2008-12-22)
>>
>> > pdf('exp.pdf',colormodel='gray')
>> > barplot(table(subset(iris,Petal.Width>1)$Species))
>> > dev.off()
>>
>> Contrary to what I was expecting the bars appear in black and not gray as
>> they are supposed to. This is not particularly serious for this toy graph
>> but for others it creates more problems.
>>
>> Interesting enough this problem does not occur with the same option on the
>> postscript() driver as it can be observed by running:
>> > postscript('exp.eps',colormodel='gray')
>> > barplot(table(subset(iris,Petal.Width>1)$Species))
>> > dev.off()
>>
>> Any help is most appreciated.
>>
>> Luis Torgo
>>
>> --
>> Luis Torgo
>>  FEP/LIAAD - INESC Porto, LA   Phone : (+351) 22 339 20 93
>>  University of Porto           Fax   : (+351) 22 339 20 99
>>  R. de Ceuta, 118, 6o          email : lto...@liaad.up.pt
>>  4050-190 PORTO - PORTUGAL     WWW   : http://www.liaad.up.pt/~ltorgo
>>
>> ______________________________________________
>> R-help@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.
>>
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to