[R] rotate levelplot

Kang Min ngokangmin at gmail.com
Mon Oct 26 03:37:38 CET 2009


Hi David,

Thanks a lot for the simple but effective solution. I got what I
wanted by doing a levelplot(t(q2)).

Kang Min

On Oct 25, 8:46 pm, David Winsemius <dwinsem... at comcast.net> wrote:
> On Oct 25, 2009, at 1:51 AM, Kang Min wrote:
>
> > Hi Milton,
>
> > The matrix can be generated using
>
> > p = matrix(1:50, nrow=5)
>
> > If I just use levelplot(p), it gives me a graph that is vertical. How
> > can I rotate it so it becomes horizontal?
> > I cannot do
>
> > q = t(p); levelplot(q)
>
> > because this is representing a map from a piece of land, transposing
> > the data will flip the map upside down laterally.
>
> You can reverse the order of the indices. I cannot quite figure out  
> which reversal will accomplish your goals because your description  
> seems ambiguous but take a look at the output of htese and you should  
> be able to apply hte strategy to your situation:
>
>   library(lattice)
> #as a courtesy to the helpeRs it's nice to reference the package in  
> which you function resides
>
>   p = matrix(1:50, nrow=5)
>   q2 = p[5:1, ] ; levelplot(q2)
>
>   levelplot(p)
>
>   q = t(p)
>   levelplot(q[10:1, ])
>
> -- David
>
>
>
>
>
> > Thanks,
> > Kang Min
>
> > On Oct 25, 12:40 pm, milton ruser <milton.ru... at gmail.com> wrote:
> >> Hi Kang,
>
> >> Could you send a reproducible sample-code?
>
> >> Bests
>
> >> miltinho
>
> >> On Sat, Oct 24, 2009 at 11:32 PM, Kang Min <ngokang... at gmail.com>  
> >> wrote:
> >>> Hi all,
>
> >>> I have a matrix with 5 rows and 10 columns, which represent the  
> >>> grids
> >>> on a rectangular map.
> >>> I used the code below to plot, but it gives me the map with the 10
> >>> columns as y-axis, and the 5 rows as the x-axis, and the (0,0) point
> >>> is at the usual bottom left hand corner. My map starts with the  
> >>> (0,0)
> >>> at the top left hand corner.
>
> >>> How can I rotate the map 90 degrees clockwise so the (0,0) starts at
> >>> the top left? That means I need the 10 columns to be x-axis. I  
> >>> cannot
> >>> transpose the matrix because the map would be laterally flipped  
> >>> over.
>
> >>> levelplot(quadsec.mat, colorkey=list(space="bottom"), scales=list
> >>> (tick.number=10), aspect=c("iso"))
>
> >>> Thanks, I'm ready to give more information if needed.
>
> >>> Kang Min
>
> >>> ______________________________________________
> >>> R-h... 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<http://www.r-project.org/posting-guide.html
>
> >>> and provide commented, minimal, self-contained, reproducible code.
>
> >>         [[alternative HTML version deleted]]
>
> >> ______________________________________________
> >> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/
> >> listinfo/r-help
> >> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
>
> > ______________________________________________
> > R-h... at r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list