0
$\begingroup$

I borrowed this code from a Wolfram demo. I looked at several answers to the general question of how to move the x-axis label from the end of the x-axis to beneath it (use Labeled instead of Plot, use Frames, etc.), but I cannot figure out how to implement those suggestions inside this relatively complicated set of nested functions. Would greatly appreciate any advice. Thanks.

Labeled[Show[p1, p2, ImageSize -> Large, GridLines -> Automatic, 
  GridLinesStyle -> Dotted, PlotRange -> {0.5, 1}, 
  AxesOrigin -> {0, 0.5}, 
  AxesLabel -> {Style["Years in Retirement", FontSize -> 12, 
     FontWeight -> Bold], 
    Style["Survival Probability", FontSize -> 12, 
     FontWeight -> Bold]}], 
 Column[{Style["Kaplan-Meier Curve of Portfolio Survival Probablity", 
    FontSize -> 18, Bold, FontFamily -> "Helvetica"], 
   Style["$50K Annual Withdrawals from $1M Portfolio", FontSize -> 14,
     Bold, FontFamily -> "Helvetica", FontColor -> Gray], 
   Style["Shows 70% Confidence Interval", FontSize -> 12, Bold, 
    FontFamily -> "Helvetica", FontColor -> Darker@Pink]}], {{Top, 
   Left}}]
$\endgroup$
3
$\begingroup$

See this question and answer, since this is a duplicate, I think. Part of the problem has to do with code formatting, so I've answered anyway.

Here is a simple example of what you might want. For the purposes of illustration, I have defined

p1 = Plot[x^2, {x, 0, 1}];
p2 = Plot[x, {x, 0, 1}];

Then:

Labeled[
 Show[p1, p2
  , ImageSize -> Large
  , GridLines -> Automatic
  , GridLinesStyle -> Dotted
  , PlotRange -> {0.5, 1}
  , AxesOrigin -> {0, 0.5}
  , Frame -> True
  , FrameLabel -> {Style["Years in Retirement", FontSize -> 12, 
     FontWeight -> Bold], 
    Style["Survival Probability", FontSize -> 12, 
     FontWeight -> Bold]}
  ]
 , Column[{Style[
    "Kaplan-Meier Curve of Portfolio Survival Probablity", 
    FontSize -> 18, Bold, FontFamily -> "Helvetica"], 
   Style["$50K Annual Withdrawals from $1M Portfolio", FontSize -> 14,
     Bold, FontFamily -> "Helvetica", FontColor -> Gray], 
   Style["Shows 70% Confidence Interval", FontSize -> 12, Bold, 
    FontFamily -> "Helvetica", FontColor -> Darker@Pink]}]
 , {{Top, Left}}]

I've added Frame -> True and replaced AxesLabel with FrameLabel. This has the side effect of adding a frame around the plot (so that there are now lines on the top and right of the plot). There are ways to remove them, but I like the look of plots with frames, so I usually leave them. By the way, formatting your code nicely as I've done above (rather than having all of the code on one line with wrapping) will help you figure out how to make these changes.

The result is:

enter image description here

$\endgroup$
  • $\begingroup$ Excellent. Worked like a charm. I was seeing the Frame->True in answers to similar questions but missing the change from AxesLabel to FrameLabel. Thanks for your time! $\endgroup$ – Dirk Cotton Jun 29 '15 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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