Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Problem with PlotLegends
Replies: 5   Last Post: Dec 15, 2012 5:48 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 895
Registered: 10/29/11
Re: Problem with PlotLegends
Posted: Dec 15, 2012 5:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

$Version

"8.0 for Mac OS X x86 (64-bit) (October 5, 2011)"

Needs["PlotLegends`"]

a = RandomReal[{2, 10}] // Rationalize[#, 0] &;
b = RandomReal[{1, 2}] // Rationalize[#, 0] &;

(f[x_, y_] = a*Sin[x] Sin[y] + b) // N

1.31591 + 6.77687 Sin[x] Sin[y]

(max = Maximize[{f[x, y],
-4 <= x <= 4, -3 <= y <= 3},
{x, y}]) // N

{8.09278, {x -> -1.5708, y -> -1.5708}}

max[[1]] === a + b

True

(min = Minimize[{f[x, y],
-4 <= x <= 4, -3 <= y <= 3},
{x, y}]) // N

{-5.46096, {x -> -1.5708, y -> 1.5708}}

min[[1]] === -a + b

True

ShowLegend[
DensityPlot[
f[x, y],
{x, -4, 4}, {y, -3, 3},
ColorFunction -> "SunsetColors",
ImageSize -> 400],
{ColorData["SunsetColors"][1 - #1] &, 32,
ToString[Round[max[[1]], 0.01]],
ToString[Round[min[[1]], 0.01]],
LegendPosition -> {1.1, -0.75},
LegendShadow -> None, LegendSize -> {.25, 1.5}}]


Bob Hanlon


On Fri, Dec 14, 2012 at 10:42 AM, Sebasti=E1n Araya <xebamadeus@gmail.com> wrote:
> Hi!! well, I'm using Mathematica 8 and really I need to create a legend for
> especific functions where exist unkonwn range (in the above example of sin
> or cos, the max and min range are -1 and 1).
>
> The mathematica tutorials learn that for create legends in densityplot, you
> can using PlotLegends where previously Needs["PlotLegends`"] is excecuted.
> But it's not working.
>
> I need you help please. Is very important solve it
>
> Thank you for you atention
>
>
> 2012/12/14 Bob Hanlon <hanlonr357@gmail.com>

>>
>> Prior to v9 use ShowLegend
>>
>> $Version
>>
>> "8.0 for Mac OS X x86 (64-bit) (October 5, 2011)"
>>
>> Needs["PlotLegends`"]
>>
>> ShowLegend[
>> DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
>> ColorFunction -> "SunsetColors",
>> ImageSize -> 400],
>> {ColorData["SunsetColors"][1 - #1] &, 32, " 1", "-1",
>> LegendPosition -> {1.1, -0.75},
>> LegendShadow -> None,
>> LegendSize -> {.2, 1.5}}]
>>
>> In V9 the functionality is built-in
>>
>> $Version
>>
>> "9.0 for Mac OS X x86 (64-bit) (November 20, 2012)"
>>
>> DensityPlot[
>> Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
>> ColorFunction -> "SunsetColors",
>> PlotLegends -> Automatic]
>>
>>
>> Bob Hanlon
>>
>>
>> On Fri, Dec 14, 2012 at 3:00 AM, <xebamadeus@gmail.com> wrote:

>> > Hi! I need your help!!. I don't understand why not working PlotLegends
>> > when I use DensityPlot.
>> >
>> > This is my problem:
>> >
>> > Needs["PlotLegends`"]
>> >
>> > DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
>> > ColorFunction -> "SunsetColors", PlotLegends -> Automatic]
>> >
>> > DensityPlot::optx: Unknown option PlotLegends in DensityPlot[Sin[x]
>> > Sin[y],{x,-4,4},{y,-3,3},ColorFunction->SunsetColors,PlotLegends->Automatic].

>> > >>
>> >
>> > DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3},
>> > ColorFunction -> "SunsetColors", PlotLegends -> Automatic]
>> >
>> > $Packages
>> >
>> > {"PlotLegends`", "ResourceLocator`", "DocumentationSearch`", \
>> > "GetFEKernelInit`", "JLink`", "PacletManager`", "WebServices`", \
>> > "System`", "Global`"}
>> >
>> > Thank you for you attention!
>> >

>
>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.