1
$\begingroup$

How to put label "Iterations" below x-axis? Possibly in an easy way without multiple commands.

a = {1, 3, 6, 3, 2};
b = {3, 2, 5, 6, 9};
c = {2, 7, 3, 1, 6};
d = {4, 2, 8, 8, 10};
am = {Position[a, Max[a]][[1, 1]], Max[a]}
bm = {Position[b, Max[b]][[1, 1]], Max[b]}
cm = {Position[c, Max[c]][[1, 1]], Max[c]}
dm = {Position[d, Max[d]][[1, 1]], Max[d]}
ListLinePlot[{a, b, c, d}, AxesLabel -> {"Iteraciones", "Objetivo"}, 
 PlotStyle -> {{Thickness[0.01], Orange}, {Dashed, 
    Thickness[0.01]}, {Thickness[0.01], Dashed, Red}}, 
 Epilog -> {PointSize[0.04], Point[{am, bm, cm, dm}]}]
$\endgroup$
  • 2
    $\begingroup$ Would you be happy to use a framed plot? Then modding to Frame -> True, FrameLabel -> {"Iteraciones", "Objetivo"} does the trick already. $\endgroup$ – Yves Klett Apr 28 '14 at 8:53
  • 3
    $\begingroup$ Without Frame you can use Labeled[(*plot*),"Iteraciones", Bottom] $\endgroup$ – Kuba Apr 28 '14 at 8:54
  • $\begingroup$ @kuba SOLVED. Thank You $\endgroup$ – Mika Ike Apr 28 '14 at 9:00
  • $\begingroup$ @YvesKlett SOLVED. Thank you. $\endgroup$ – Mika Ike Apr 28 '14 at 9:01
  • 3
    $\begingroup$ When you type "label plot below" you will get a first link to: mathematica.stackexchange.com/q/17747/5478 so next time please try to look for the answer via search engine in top right corner first :) $\endgroup$ – Kuba Apr 28 '14 at 9:02
4
$\begingroup$

Personally, I prefer Frame->True for most of my plots.

a = {1, 3, 6, 3, 2};
b = {3, 2, 5, 6, 9};
c = {2, 7, 3, 1, 6};
d = {4, 2, 8, 8, 10};
max = {Position[#, Max[#]][[1, 1]], Max[#]} & /@ {a, b, c, d};
ListLinePlot[{a, b, c, d}, Frame -> True, 
 FrameLabel -> {Style["Iteraciones", Red, Large], 
   Style["Objetivo", Blue, Small]}, 
 PlotStyle -> {{Thickness[0.01], Orange}, {Dashed, 
    Thickness[0.01]}, {Thickness[0.01], Dashed, Red}}, 
 Epilog -> {PointSize[0.04], Point[max]}]

Mathematica graphics

| improve this answer | |
$\endgroup$
6
$\begingroup$

This is just a modification of Yves' answer. If you really don't want a framed look, you can expand out the option value of the Framed option to address each side individually, like this:

a = {1, 3, 6, 3, 2};
b = {3, 2, 5, 6, 9};
c = {2, 7, 3, 1, 6};
d = {4, 2, 8, 8, 10};
max = {Position[#, Max[#]][[1, 1]], Max[#]} & /@ {a, b, c, d};
ListLinePlot[{a, b, c, d}, Frame -> {{True, False}, {True, False}}, 
 PlotRangePadding -> {{0.2, 0.5}, {0, 0.5}}, 
 FrameLabel -> {Style["Iteraciones", Red, Large], 
   Style["Objetivo", Blue, Small]}, 
 PlotStyle -> {{Thickness[0.01], Orange}, {Dashed, 
    Thickness[0.01]}, {Thickness[0.01], Dashed, Red}}, 
 Epilog -> {PointSize[0.04], Point[max]}]

enter image description here

Notice that I have also added some PlotRangePadding to avoid the big dots being cut off.

$\endgroup$
  • $\begingroup$ And here was I thinking that this was such a trivial addition to Yves' answer that I should CW it. Three up votes in an hour? $\endgroup$ – Verbeia Apr 28 '14 at 11:49
  • $\begingroup$ Well, it is a useful addition :D $\endgroup$ – Yves Klett Apr 28 '14 at 14:25

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