5
$\begingroup$

I want to have thicker lines in the legends of this plot:

historyobjetivomejor = {10, 15, 20, 30, 35}
historyobjetivomedia = {6, 8, 10, 13, 15}
historyobjetivopeor = {6, 3, 5, 7, 8}

ListLinePlot[{historyobjetivomejor, historyobjetivomedia, historyobjetivopeor}, 
  PlotStyle -> {Thickness[0.008]}, 
  AxesLabel -> {"Generacion", "Objetivo"}, 
  LabelStyle -> {24, Bold}, 
  ImageSize -> Large, 
  PlotLegends -> {"Max", "Mea", "Min"}, 
  PlotStyle -> Thickness[0.005], 
  AxesStyle -> Thickness[0.005]]

I was trying with options from other posts, but without good result My last attemp was

ListLinePlot[{historyobjetivomejor, historyobjetivomedia, historyobjetivopeor},  
  PlotStyle -> {Thickness[0.008]}, 
  AxesLabel -> {"Generacion", "Objetivo"}, 
  ImageSize -> Large, 
  PlotLegends -> [{"Max", "Mea", "Min"}, 
  LabelStyle -> {Bold, 20}, 
  LegendMarkerSize -> {40, 10}], 
  PlotStyle -> Thickness[0.005], 
  AxesStyle -> Thickness[0.005]]
$\endgroup$

3 Answers 3

11
$\begingroup$

AbsoluteThickness is another useful approach:e.g.

op = Table[AbsoluteThickness[2], {3}];
leg = LineLegend[Automatic, {"Max", "Mea", "Min"}];
ListLinePlot[{historyobjetivomejor, historyobjetivomedia, 
  historyobjetivopeor}, AxesLabel -> {"Generacion", "Objetivo"}, 
 PlotStyle -> op, PlotLegends -> leg]

enter image description here

Varying thickness: enter image description here

using:

Manipulate[
 ListLinePlot[{historyobjetivomejor, historyobjetivomedia, 
   historyobjetivopeor}, AxesLabel -> {"Generacion", "Objetivo"}, 
  PlotStyle -> Table[AbsoluteThickness[t], {3}], 
  PlotLegends -> leg], {t, Range[2, 5]}]
$\endgroup$
3
  • $\begingroup$ @ubpdqn Thank you very much :-) Off-topic... :-) A curiosity. How do you create the animated gif? :-) Any suggestion? $\endgroup$
    – Mika Ike
    Commented Jun 10, 2014 at 8:40
  • 1
    $\begingroup$ @MikaIke I use LICEcap freeware...here: licecap.en.softonic.com is a site but you can search if does not suit your platform $\endgroup$
    – ubpdqn
    Commented Jun 10, 2014 at 9:04
  • $\begingroup$ @ubpdqn Thnk you very much. I´ll try it $\endgroup$
    – Mika Ike
    Commented Jun 10, 2014 at 9:21
5
$\begingroup$

I don't recall a direct way of doing this with normal legending, but you can accomplish same with something like:

ListLinePlot[{historyobjetivomejor, historyobjetivomedia, 
  historyobjetivopeor}, PlotStyle -> {Thickness[0.008]}, 
 AxesLabel -> {"Generacion", "Objetivo"}, LabelStyle -> {24, Bold}, 
 ImageSize -> Large, 
 PlotLegends -> SwatchLegend[Automatic, {"Max", "Mea", "Min"}, 
                   LegendMarkerSize -> {{30, 4}}, 
                   LegendMarkers -> Graphics[{Thickness[.2], Line[{{0, 0}, {10, 0}}]}]], 
 PlotStyle -> Thickness[0.005], AxesStyle -> Thickness[0.005]]

enter image description here

$\endgroup$
1
$\begingroup$

You can use the option "BaseStyle" -> Thickness[.25] inside LineLegend without having to change the thickness in the main plot:

ListLinePlot[{historyobjetivomejor, historyobjetivomedia, historyobjetivopeor}, 
 PlotLegends -> LineLegend[Automatic, {"Max", "Mea", "Min"}, "BaseStyle"->Thickness[.25]]]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks for this post - this is the easiest way! $\endgroup$
    – smörkex
    Commented May 16, 2018 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.