Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This command will produce a chart with two lines on it.

DateListPlot[{CapReg, Equity},  Joined -> True ]

What I would like to do is add a label above the chart "CapReg" in red, and a label below the chart "Equity" in blue. Then I would like to have the color of the CapReg line be red, and the line for Equity be blue. Any ideas?

Many thanks in advance.

share|improve this question
    
You've looked into PlotStyle? –  J. M. Jun 23 '12 at 1:11

1 Answer 1

up vote 4 down vote accepted

Something like the following?

 data1 = {{{2006, 10, 1}, 10}, {{2006, 10, 15}, 12}, 
          {{2006, 10, 30},15}, {{2006, 11, 20}, 20}};
 data2 = {{{2006, 10, 5}, 15}, {{2006, 10, 20}, 8}, 
          {{2006, 11, 10},  5}, {{2006, 11, 15}, 1}};
 DateListPlot[{data1, data2}, PlotStyle -> {Red, Blue}, Joined -> True,
 PlotLabel ->  Row[{Style["CapReg", Red, "Section"],Spacer[15],
                    Style["Equity", Blue, "Section"]}]]

enter image description here

EDIT: For placing parts of plot label in various places, you can use option FrameLabel or the built-in function Labeled as follows:

DateListPlot[{data1, data2}, PlotStyle -> {Red, Blue}, Joined -> True,
FrameLabel -> {{"values", None}, {Column[{"dates", Style["Equity", Blue, "Section"]}, 
 Alignment -> Center], Style["CapReg", Red, Bold, "Section"]}}]

enter image description here

 Labeled[
 DateListPlot[{data1, data2}, PlotStyle -> {Red, Blue}, Joined -> True, 
 FrameLabel -> {{"values", None}, {"dates", None}}], 
  {Style["CapReg", Red, Bold, "Section"], Style["Equity", Blue, Bold, "Section"]},
  {Top, Bottom}]

enter image description here

share|improve this answer
    
@MikeHoneychurch, thank you for the edit:) I was puzzled for a second itlooked as if Ctrl-C was enough to cut and paste into the right place in SE :) –  kguler Jun 23 '12 at 1:32
    
No worries. Also minor change in using Spacer rather than a string space. I prefer Spacer since it allows more flexibility. –  Mike Honeychurch Jun 23 '12 at 1:40
    
Thank you, it works good. Is there any way the "Equity" la bel could be placed under the Chart? –  John Jun 23 '12 at 2:39
    
@John, you can use FrameLabel or Labeled to place the labels in various places. I will edit the post with examples in a moment. –  kguler Jun 23 '12 at 3:36
    
kguler, thank you for your help. Hope you have a good weekend. –  John Jun 23 '12 at 17:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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