MathGroup Archive 2003

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

Search the Archive

RE: Display of legend in MultiListPlot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39557] RE: [mg39536] Display of legend in MultiListPlot
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 23 Feb 2003 05:00:00 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Marcus,

MultipleListPlot and Legends are generally a pain in the neck. They are a
difficult method to make a mediocre graph.

I would consider it an undesirable feature that Mathematica does not pick up
the TextStyle for the Legend.

In any case, you could wrap the Legend text in StyleForm to get the desired
FontSize.  Here is an example with some made up data. I slightly enlarged
the font size because I couldn't even read what you had. I moved the
location to accommodate the data that I made up.

Needs["Graphics`MultipleListPlot`"]

help1 = Table[{x, 1 + 0.8x}, {x, 0, 10, 0.25}];
help2 = Table[{x, 1 + 0.5x}, {x, 0, 10, 0.25}];

MultipleListPlot[help1, help2,
  PlotJoined -> True, Frame -> True,
  PlotRange -> {{-0.01, 10.01}, {1, 8}},
  GridLines -> {{2, 4, 6, 8}, Automatic},
  TextStyle -> {FontSize -> 10, FontFamily -> "Times New Roman"},
  PlotLegend -> {StyleForm["initial", FontSize -> 10],
        StyleForm[ "3 mos.", FontSize -> 10]},
  LegendPosition -> {-0.8, 0.14},
  LegendSize -> {0.8, 0.4},
  FrameLabel -> {"Maturity  in  years", "Yield  in  %"},
  SymbolShape -> {None, None},
  PlotStyle -> {{Thickness[0.008], GrayLevel[0]}, {Dashing[{0.01}],
        Thickness[0.008], GrayLevel[0.2]}},
    ImageSize -> 500];

But I don't think that looks very great. We could work to adjust the size of
the Legend and then the spacings withing the legend. It is generally a lot
of work and I am not going to undertake it. Generally Legends are not very
good because they take a lot of space, convey little information and divert
the viewer of the graphic from the real information you are trying to
present.

So I would throw MultipleListPlot (but its PlotSymbol and MakeSymbol
routines are useful) and Legend into the ashcan and make your plot the
following way...

Show[Graphics[
      {Thickness[0.008], GrayLevel[0],
        Line[help1],
        Text["Initial", {5.35558, 5.67536}, {1, 0}],

        Dashing[{0.01}], Thickness[0.008], GrayLevel[0.2],
        Line[help2],
        Text["3 Months", {6.11624, 3.69516}, {-1, 0}]}],

    Frame -> True,
    TextStyle -> {FontSize -> 10, FontFamily -> "Times New Roman"},
    PlotRange -> {{-0.01, 10.01}, {1, 8}},
    GridLines -> {Table[{x, {GrayLevel[0.8]}}, {x, 2, 8, 2}],
        Table[{x, {GrayLevel[0.8]}}, {x, 1, 8, 1}]},
    FrameLabel -> {"Maturity  in  years", "Yield  in  %"},
    ImageSize -> 500];

You could also have plotted the points by Mapping Point or PlotSymbol onto
help1 and help2.

Heavy grid lines produce clutter and detract from the information. In the
above plot I changed the girds to light gray, which is all that is
necessary. This is Edward Tufte's principle of "Minimum Effective
Difference". Use the minimum effective difference to convey subsidiary
information. It leaves more visual room for the real data to shine through.

Instead of a Legend, I put direct labels on the two lines using the Text
statement. I clicked off the coordinates from the plot and copied them into
the Text statements.

Don't you think that looks better?

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

From: Marcus Schulmerich [mailto:mschulme at yahoo.com]
To: mathgroup at smc.vnet.net

Hello,

I have a problem with Mathematica which I could not solve with the online
help
or any book so far. I want to display graphs with MultiListPlot. In the
files
data1.dat and data2.dat
I have the appropriate data and the command I use are the following:



<<Graphics`MultipleListPlot`

help1 = Import["data1.dat", "table"]

help2 = Import["data2.dat", "table"]

MultipleListPlot[help1, help2,
  PlotJoined -> True, Frame -> True,
  PlotRange -> {{-0.01, 10.01}, {1, 8}},
  GridLines -> {{2, 4, 6, 8}, Automatic},
  TextStyle -> {FontSize -> 7, FontFamily -> "Times New Roman"},
  PlotLegend -> {"initial", "3 mos."},
  LegendPosition -> {0.25, -0.35},
  LegendSize -> {0.8, 0.4},
  FrameLabel -> {"Maturity  in  years", "Yield  in  %"},
  SymbolShape -> {None, None},
  PlotStyle -> {{Thickness[0.008], GrayLevel[0]}, {Dashing[{0.01}],
        Thickness[0.008], GrayLevel[0.2]}}]



The display of the two graphs works fine but the problem is: While the names
of the axis are, as
I specified, in FontSize=7 and FontFamily=Times New Roman, the display of
the legend is in a
different FontSize and Fontfamily which I cannot specify (at least I don't
know how to do that).
I want the legend to be in the same FontSize and Fontfamily as the names on
the axix. How can I
do this, i.e., what commands do I need to add above to achieve this??


thx
Marcus



  • Prev by Date: Re: Finding the closest number from a list
  • Next by Date: RE: Programing in MATHEMATICA
  • Previous by thread: Display of legend in MultiListPlot
  • Next by thread: Re: Display of legend in MultiListPlot