MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: x and y labels in ArrayPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113728] Re: x and y labels in ArrayPlot
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 9 Nov 2010 03:53:40 -0500 (EST)

You can do something like the following but it would have to be adjusted for any changes in the size of the ArrayPlot 

data = {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}, {4, 5, 6}};
yLabels = {"axxx", "bxxx", "cxxx"};
xLabels = {"A", "B", "C", "D"};

Grid[{
  {"", Row[Rotate[#, 45 Degree] & /@
     yLabels, 
    StringJoin[Table[" ", {12}]],
    Alignment -> {Center, Baseline}]},
  {Column[xLabels, Spacings -> 5],
   ArrayPlot[data, Frame -> None,
    ImageSize -> 324]}}]


Bob Hanlon


---- Gordon Robertson <grobertson at bcgsc.ca> wrote: 

=============
Thank you.

Is it possible to hide the Frame's black line (which surrounds the 
shaded checkerboard ArrayPlot), while retaining the FrameTicks? 
Frame->False removes the outline and the labels.

G

Bob Hanlon wrote:
> Use FrameTicks with the ticks suppressed (zero length). I'm not sure where you want the labels since you say the rows are lower case but you want the xLabels (upper case) to the left (rows). Adjust the following as appropriate.
>
> data = {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}, {4, 5, 6}};
> yLabels = {"axxx", "bxxx", "cxxx"};
> xLabels = {"A", "B", "C", "D"};
> ArrayPlot[data, FrameTicks ->  {
>     {Transpose[{
>        Range[Length[xLabels]],
>        xLabels,
>        Table[0, {Length[xLabels]}]}],
>      None},
>     {None,
>      Transpose[{
>        Range[Length[yLabels]],
>        Rotate[#, 45 Degree]&  /@ yLabels,
>        Table[0, {Length[yLabels]}]}]}}]
>
>
> Bob Hanlon
>
> ---- Gordon Robertson<grobertson at bcgsc.ca>  wrote:
>
> =============
>
> I would like to plot an array of integer values, and to put labels on
> each row (a,c,b) and column (A,B,C) of the array, with x-labels on the
> left and y-labels above and potentially rotated by 45 or 90 degrees.
> ArrayPlot seems appropriate, but I do not see how to add the labels.
> I've tried to check the Help documentation carefully, including
> MatrixPlot and alternatives, and the WRI demonstrations.
>
> data = {{1, 2, 3},
>     {2, 3, 4},
>     {3, 4, 5}}
> yLabels = {"a", "b", "c"}
> xLabels = {"A", "B", "C"}
> ArrayPlot[data]
>
> Thanks for your help.
>
> Gordon

-- 
Gordon Robertson
BC Cancer Agency Genome Sciences Centre
Vancouver BC Canada
604-707-5800
www.bcgsc.ca




  • Prev by Date: Re: How to apply Fourier transform to speech signals?
  • Next by Date: Re: pure function
  • Previous by thread: Re: x and y labels in ArrayPlot
  • Next by thread: Anyone ever used the Mac app called ForeverSave with Mathematica?