Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Legend, mathematica

  1. Mar 4, 2010 #1
    Hi, can anyone tell me, how to make the lines in a legend more legible (or larger)?

    When I am making a legend, the colored lines are too faint, so that I can't see what they refer to.

    Thank you,
    Juliane
     
  2. jcsd
  3. Mar 4, 2010 #2

    Hepth

    User Avatar
    Gold Member

    Can you post a sample of the legend you're trying to make?

    Code (Text):
    Needs["PlotLegends`"];


    Plot[{Sin[x], Cos[x]}, {x, 0, 2 Pi}, PlotLegend -> {"sine", "cosine"}]

     
    Gives a plot with a legend built in, but you can also make your own.

    Code (Text):

    LGN = Show[
      Graphics[Legend[{{Graphics[{Thick, Purple, Line[{{0, 0}, {1, 0}}]}],
           "sin"}, {Graphics[{Thick, Red, Line[{{0, 0}, {1, 0}}]}],
          "cos"}}]]]
     
    And just do a bunch of editing to make it look how you want.

    By default the legend of the plot is the same line as the one drawn in the plot, and I don't see any directives to change that. But making it yourself you can specify the thickness.

    Or you can just change the thickness of the lines on the plot itself and that will be reflected in the legend.
     
    Last edited: Mar 4, 2010
  4. Mar 5, 2010 #3
    Here is the plot I want to make:
    L[x_] := (1/
    2) (BesselI[0, 2 x] + BesselI[2, 2 x])/(BesselI[1,
    2 x]) - (1/(2 x))
    L0[x_] := (1/
    2) (BesselI[0, x] BesselI[1, x] -
    BesselI[-1, x] BesselI[2, x])/((BesselI[0, x])^2 -
    BesselI[1, x] BesselI[-1, x])
    L1[x_] := (1/
    2) (BesselI[1, x] BesselI[2, x] -
    BesselI[0, x] BesselI[3, x])/((BesselI[1, x])^2 -
    BesselI[2, x] BesselI[0, x]) + (1/x)
    L2[x_] := (1/
    2) (BesselI[2, x] BesselI[3, x] -
    BesselI[1, x] BesselI[4, x])/((BesselI[2, x])^2 -
    BesselI[3, x] BesselI[1, x]) + (2/x)
    Needs["PlotLegends`"]
    Plot[Evaluate[{L[x], L0[x], L1[x], L2[x]}], {x, 0, 10},
    PlotRange -> {0, 1.4}, Frame -> True,
    FrameLabel -> {Style[OverHat[m], 12, FontWeight -> "Bold"],
    Style[Subscript[AngleBracket[\[Psi]\[Psi]], \[Nu]], 12,
    FontWeight -> "Bold"]},
    PlotStyle -> {{Blue, Dashing[0], Thickness[0.0029]}, {Darker[Purple],
    Dashing[0.015], Thickness[0.0029]}, {Darker[Red], Dashing[0.01],
    Thickness[0.0029]}, {Darker[Green], Dashing[0.03],
    Thickness[0.0029]}}, BaseStyle -> {FontSize -> 10},
    PlotLegend -> {Style[\[LeftAngleBracket]\[Psi]\[Psi]\
    \[RightAngleBracket], 10, FontWeight -> "Bold"],
    Style["\[Nu]=0", 10, FontWeight -> "Bold"],
    Style["\[Nu]=1", 10, FontWeight -> "Bold"],
    Style["\[Nu]=2", 10, FontWeight -> "Bold"]},
    LegendPosition -> {0.9, -0.4}, LegendTextSpace -> .8,
    LegendShadow -> {.05, -.05}, LegendSize -> 1]

    The Legend-lines do not get any larger when I increase the thickness (in what stands above).
    Could you also tell me how to make an overline on the first Psi in "AngleBracket[\[Psi]\[Psi]]". No matter what I do, the overline keeps coming on the second Psi.

    Thank you so much,
    Juliane
     
  5. Mar 5, 2010 #4

    Hepth

    User Avatar
    Gold Member

    I'll take a look.

    Right off the bat to put the bar over the first psi put quotes around the whole thing, including the brackets : "<sbar s>" and itll put it on the correct one. If you dont it applies order of operations on it and alphabetically I guess the bar comes after non bar.
     
  6. Mar 7, 2010 #5
    Hi, when I write this: "<sbar s>", mathematica writes "bar" on top of the letter - it doesn't draw a line??
     
  7. Mar 7, 2010 #6

    Hepth

    User Avatar
    Gold Member

    I didn't mean it literally. I mean where you have :

    PlotLegend -> {Style[\[LeftAngleBracket]\[Psi]\[Psi]\
    \[RightAngleBracket], 10, FontWeight -> "Bold"],

    USE

    PlotLegend -> {Style["\[LeftAngleBracket]\[Psi]\[Psi]\
    \[RightAngleBracket]", 10, FontWeight -> "Bold"],

    notice the quotes I added.
     
  8. Mar 8, 2010 #7
    But there is no overbar in what you write??
    Sorry I don't understand you.
     
  9. Mar 8, 2010 #8

    Hepth

    User Avatar
    Gold Member

    ah sorry.

    "\[LeftAngleBracket]\!\(\*OverscriptBox[\"\[Psi]\", \"_\"]\)\[Psi]\
    \[RightAngleBracket]"
     
  10. Mar 8, 2010 #9

    Hepth

    User Avatar
    Gold Member

    its the quotes that forces it to be read as text rather than input. input will normally be ordered alphabetically.
     
  11. Mar 9, 2010 #10
    Thank you so much.

    I'm handing in my master thesis tomorrow - could you please tell me, how to incorporate the legend (LGN=...) in the plot?

    Once again, thank you.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook