[R] image.plot adding x-axis labels. Please Help

ilai keren at math.montana.edu
Wed Apr 4 18:23:13 CEST 2012


On Wed, Apr 4, 2012 at 6:05 AM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> On Apr 3, 2012, at 11:16 PM, David Lyon wrote:
>
>> Sorry that didnt work for me, any ideas?
>
>
> You _could_ indicate which package the image.plot function comes from. You
> _could_ include dput on a sufficient segment of `data1` to offer a
> reproducible test case. You _could_ indicate in what fashion the axis() call
> "didn't work". I used to look such matters up, add code and make guesses,
> but got tired of doing extra work that was really the responsibility of the
> questioner.
>
> --
> David

Thank you David, you're absolutely right. The critical point here is
par settings of fields::image.plot not the axis(1,at=?...) as could be
understood from the original partial question.

I forgot to cc the list on my private communications with the OP.
Future googlers, the same solution can be achieved with

A<- matrix(1:50,nr=10)
par(mar=c(5.1,2.1,4.1,4.1))
image(t(A),axes=F,col='transparent')
axis(1,at=seq(0,1,l=ncol(A)),labels=LETTERS[1:ncol(A)])
require(fields)
image.plot(t(A),add=T,legend.mar=3.1)


Cheers

>
>>
>>
>> ----- Original Message -----
>> From: ilai <keren at math.montana.edu>
>> To: David Lyon <david_lyon3 at yahoo.com>
>> Cc: "r-help at r-project.org" <r-help at r-project.org>
>> Sent: Tuesday, April 3, 2012 10:43 PM
>> Subject: Re: [R] image.plot adding x-axis labels. Please Help
>>
>> On Tue, Apr 3, 2012 at 7:25 PM, David Lyon <david_lyon3 at yahoo.com> wrote:
>>>
>>> if I had a data file like this:
>>> 1.42 1.29 -0.13
>>> 1.46 1.34 -0.12
>>> 1.45 1.32 -0.13
>>> 1.36 1.26 -0.10
>>> 1.33 1.29 -0.04
>>>
>>> I want to create a image plot like this:
>>> data1<-read.table("A")
>>>
>>> image.plot(t(data1), axes=FALSE, xlab=NA, ylab=NA)
>>>
>>> I cant get the labels for the x axis right can some kind person help me?
>>
>>
>> axis(1,at=seq(0,1,l=ncol(data1)),labels=LETTERS[1:ncol(data1)])
>>
>>
>>> axis(1.....???????.....labels=c("A", "B", "C"))
>>>
>>>
>>> Many thanks in advance!
>>>
>>> ______________________________________________
>>> 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.
>>
>>
>> ______________________________________________
>> 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.
>
>
> David Winsemius, MD
> West Hartford, CT
>



More information about the R-help mailing list