I have been using ArrayPlot
to show off some information. Currently, my datasets are like so:
data1={2, 6, 3, 4, 8, 5, 13, 11, 33, 21, 29, 21, 42, 29, 36};
data2={0, 1, 9, 1, 3, 0, 5, 3, 20, 16, 4, 13, 7, 10, 7};
data3={10, 3, 2, 0, 2, 1, 0, 0, 14, 2, 1, 12, 6, 0, 10};
data4={0, 0, 0, 2, 0, 1, 4, 0, 0, 4, 0, 4, 1, 3, 2};
data5={0, 3, 0, 3, 0, 0, 0, 3, 3, 2, 1, 14, 4, 2, 4};
etc.
The plot command
ArrayPlot[{globeCHR, starCHR, telegramCHR, gazetteCHR, citizenCHR},
FrameTicks -> All]
reveals the following:
So far so good - it vividly shows what I am trying to visualize.
The problem comes with the following. I would like to give my datasets along the y axis names: i.e. instead of "1" it might say "Cats" and instead of "2" it might say "Dogs." Similarly, the bottom axis needs to go from 1997 to 2010 (years).
I have generated a list of the years as such yearlist = Range[1997, 2011, 1]
, which lines up in length to the datasets. Matched pairs of data created by Transpose@
the two lists hasn't worked either..
Would there be a way to have the x axis demonstrate the text of the datasets, and the y axis show the data progressing from the year 1997 to 2010? Thank you very much.
Answer
The FrameTicks
should be entered in the following format:
FrameTicks->{
{{ytick1, yvalue1}, {ytick2, yvalue2},...},
{{xtick1, xvalue1}, {xtick2, xvalue2},...}
}
So here's an example for your case that shows how to label the ticks:
xticks = Transpose[{Range@15, Range[1997, 2011]}];
yticks = Transpose[{Range@5, {"Cats", "Dogs", "Sheep", "Frogs", "Mice"}}];
ArrayPlot[RandomReal[1, {5, 15}], FrameTicks -> {yticks, xticks}]
Comments
Post a Comment