Re: ListDensityPlot Legend?
- To: mathgroup at smc.vnet.net
- Subject: [mg58663] Re: [mg58653] ListDensityPlot Legend?
- From: "David Park" <djmp at earthlink.net>
- Date: Wed, 13 Jul 2005 03:28:55 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Juergen, How about something like the following? Needs["Graphics`Colors`"] matrix = Table[Random[Integer, {0, 2}], {25}, {25}]; colorfunc[z_] := Switch[z, 0, DodgerBlue, 1, LimeGreen, 2, Apricot] mplot = ListDensityPlot[matrix, Frame -> False, ColorFunction -> colorfunc, ColorFunctionScaling -> False, DisplayFunction -> Identity]; Show[Graphics[ {Rectangle[{0, 0}, {1, 1}, mplot], colorfunc[0], Rectangle[{1.05, 0.5}, {1.15, 0.6}], colorfunc[1], Rectangle[{1.05, 0.6}, {1.15, 0.7}], colorfunc[2], Rectangle[{1.05, 0.7}, {1.15, 0.8}], Black, Text[0, {1.1, 0.55}], Text[1, {1.1, 0.65}], Text[2, {1.1, 0.75}], Text["Data Matrix", {0.2, 1.05}, {-1, 0}]}], PlotRange -> {{-0.05, 1.3}, {-0.05, 1.1}}, AspectRatio -> Automatic, TextStyle -> {FontSize -> 14, FontWeight -> "Bold"}, Background -> Linen, ImageSize -> 450]; David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: juejung [mailto:juejung at indiana.edu] To: mathgroup at smc.vnet.net dear mathgroup, how does one add a legend to a ListDensityPlot. i've a matrix that contains only 0,1 or 2 entries. ListDensityPlot plots the regions in three different colors. i would like to add a legend that indicates the colors and their corresponding numbers (0,1, or 2). Tom Wickham-Jones' ExtendGraphics package is doing almost what i want for ListContourPlot, however, for ListDensityPlot it's not working. Any ideas? thanks juergen