[R] image plot with multiple x values
roger koenker
rkoenker at uiuc.edu
Fri Aug 17 21:47:32 CEST 2007
If you are willing to go to the bother of representing your data
as a sparse matrix, the package SparseM has a version of image()
that will do what you would like to do, I believe.
url: www.econ.uiuc.edu/~roger Roger Koenker
email rkoenker at uiuc.edu Department of Economics
vox: 217-333-4558 University of Illinois
fax: 217-244-6678 Champaign, IL 61820
On Aug 17, 2007, at 1:51 PM, baptiste Auguié wrote:
> Hi,
>
> New to R, I don't find a way to plot the following data with image():
>
> x is a N * M matrix
> y is a vector of length M
> z is a N*M matrix
>
> I wish to plot z as a greyscale image, but my x axis is different for
> every row of the z data.
>
> Here is a minimal example,
>
>> theta<-c(3:6) # N
>> y<-c(1:5) # M
>>
>> x<-theta%*%t(y)# N * M
>> z<-sin(x) # N * M
>>
>> image(z)
>
> This doesn't give what I want, as the x axis needs to be shifted as
> we go from line to the following. (probably clearer if you plot
> matplot(x,z): the curves are shifted)
>
> The way I see it, I need either to construct a bigger matrix with all
> possible values of x giving the new dimension and arbitrary values
> for the missing points, or find a plotting function that would plot
> lines by lines. The ordering of the x and z values is giving me a
> headache on the first idea, and I can't find any option / alternative
> to image.
>
> Thanks in advance!
>
> baptiste
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
More information about the R-help
mailing list