Discussion:
how to add color legend bar to a ListContourPlot
(too old to reply)
Ted Sariyski
2012-02-02 10:05:31 UTC
Permalink
Hi,
I want to add a color legend to a ListContourPlot. I tried ShowLegend e.g.

ShowLegend[ ListContourPlot[xyDat, {ColorData["LakeColors"][#1] &, 10, "
1", "-1"]

but I don't know how to make the ColorFunction of ListContourPlot
consistent with ColorData of ShowLegend. Or may be there is a different
way of doing this?

Any help will be greatly appreciated.
Thanks,
--Ted
Bob Hanlon
2012-02-03 07:10:59 UTC
Permalink
Needs["PlotLegends`"]

xyDat = Table[Sin[i + j^2],
{i, 0, 3, 0.1}, {j, 0, 3, 0.1}];

ShowLegend[ListContourPlot[xyDat],
{ColorData["LakeColors"][1 - #1] &, 10, "1", "-1",
LegendPosition -> {1.1, -.4}}]


Bob Hanlon
Post by Ted Sariyski
Hi,
I want to add a color legend to a ListContourPlot. I tried ShowLegend e.g.
ShowLegend[ ListContourPlot[xyDat, {ColorData["LakeColors"][#1] &, 10, "
1", "-1"]
but I don't know how to make the ColorFunction of ListContourPlot
consistent with ColorData of ShowLegend. Or may be there is a different
way of doing this?
Any help will be greatly appreciated.
Thanks,
--Ted
Ted Sariyski
2012-02-06 07:45:43 UTC
Permalink
Hi Bob,

I still have difficulties how to make it. The function I use,
imsUnstructuredContourPlotis, is based on ListContourPlot and is a
function from the IMTEK package. imsUnstructuredContourPlot returns a
Graphics and has Options set to:

Options[imsUnstructuredContourPlot]={Contours->10,Mesh->False,ColorFunction->(Hue[(#1
2)/3]&),ColorFunctionScaling->True,ContourShading->True}

I do not feel comfortable to mess up with IMTEK. Given a Graphics object
built with ColorFunction -> Hue[#1]& how can I append a legend?

Thanks in advance,
--Ted
Post by Bob Hanlon
Needs["PlotLegends`"]
xyDat = Table[Sin[i + j^2],
{i, 0, 3, 0.1}, {j, 0, 3, 0.1}];
ShowLegend[ListContourPlot[xyDat],
{ColorData["LakeColors"][1 - #1]&, 10, "1", "-1",
LegendPosition -> {1.1, -.4}}]
Bob Hanlon
2012-02-06 07:46:14 UTC
Permalink
I don't have an IMTEK package. Try reversing the labels in the legend
specification. The legend is then "upside down"; however, it is
correct.

Needs["PlotLegends`"]

xyDat = Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}];

ShowLegend[
ListContourPlot[xyDat], {ColorData["LakeColors"][1 - #] &, 10, "1", "-1",
LegendPosition -> {1.1, -.4}}]

ShowLegend[
ListContourPlot[xyDat], {ColorData["LakeColors"][#] &, 10, "-1", "1",
LegendPosition -> {1.1, -.4}}]

Alternatively, build your own legend from primitives.


Bob Hanlon



Bob Hanlon
Post by Bob Hanlon
Needs["PlotLegends`"]
xyDat = Table[Sin[i + j^2],
{i, 0, 3, 0.1}, {j, 0, 3, 0.1}];
ShowLegend[ListContourPlot[xyDat],
{ColorData["LakeColors"][1 - #1] &, 10, "1", "-1",
LegendPosition -> {1.1, -.4}}]
Bob Hanlon
Post by Ted Sariyski
Hi,
I want to add a color legend to a ListContourPlot. I tried ShowLegend e.g.
ShowLegend[ ListContourPlot[xyDat, {ColorData["LakeColors"][#1] &, 10, "
1", "-1"]
but I don't know how to make the ColorFunction of ListContourPlot
consistent with ColorData of ShowLegend. Or may be there is a different
way of doing this?
Any help will be greatly appreciated.
Thanks,
--Ted
David Skulsky
2012-02-07 09:06:55 UTC
Permalink
I asked a similar question on Stack Exchange just a few days ago. You might find this helpful:

http://mathematica.stackexchange.com/questions/1300/listplot-with-each-point-a-different-color-and-a-legend-bar

David

Loading...