Increasing Legibility of Legend Lines in Mathematica

Click For Summary

Discussion Overview

The discussion revolves around enhancing the legibility of legend lines in Mathematica plots, specifically addressing issues with line thickness and the placement of overlines in text. Participants explore methods to improve visual clarity in legends and share code snippets for creating custom legends.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • Juliane seeks advice on making legend lines more visible in Mathematica plots, expressing frustration with their faintness.
  • One participant suggests using custom graphics for legends, allowing for specified thickness, and notes that changing the plot line thickness will also affect the legend.
  • Juliane provides a complex function and plot setup, indicating that increasing line thickness does not affect the legend lines as expected.
  • Another participant proposes a method to correctly place an overline on the first Psi in the legend text by using quotes around the entire expression.
  • Juliane expresses confusion regarding the application of quotes and the resulting output, prompting further clarification from other participants.
  • A later reply clarifies that using quotes forces Mathematica to interpret the input as text rather than applying order of operations, which affects how the overline is rendered.
  • Juliane requests assistance on incorporating the custom legend into her plot, indicating a need for further guidance as she prepares to submit her master thesis.
  • Areas of Agreement / Disagreement

    Participants present various methods and suggestions, but there is no consensus on the best approach to achieve the desired legend appearance or the correct implementation of the overline.

    Contextual Notes

    Some participants' suggestions depend on specific formatting and syntax in Mathematica, which may not be universally applicable. The discussion includes unresolved technical details regarding the legend's appearance and the handling of text formatting.

    Who May Find This Useful

    This discussion may be useful for Mathematica users looking to improve the visual presentation of plots, particularly in academic or professional contexts where clarity in legends is essential.

Juliane
Messages
8
Reaction score
0
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
 
Physics news on Phys.org
Can you post a sample of the legend you're trying to make?

Code:
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:
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:
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
 
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 don't it applies order of operations on it and alphabetically I guess the bar comes after non bar.
 
Hi, when I write this: "<sbar s>", mathematica writes "bar" on top of the letter - it doesn't draw a line??
 
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.
 
But there is no overbar in what you write??
Sorry I don't understand you.
 
ah sorry.

"\[LeftAngleBracket]\!\(\*OverscriptBox[\"\[Psi]\", \"_\"]\)\[Psi]\
\[RightAngleBracket]"
 
its the quotes that forces it to be read as text rather than input. input will normally be ordered alphabetically.
 
  • #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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K