Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5817

Re: Using colored text in PlotLabel

From "McHale, Paul" <Paul.McHale@excelitas.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Using colored text in PlotLabel
Date 2011-10-23 10:31 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j80qeh$aej$1@smc.vnet.net> (permalink)
References <201108031106.HAA10819@smc.vnet.net>

Show all headers | View raw


My favorite means of creating a quick legend is:

(* Plot    *)
Plot[{x, x^2} , {x, -10, 10}, PlotRange -> All,
 PlotLabel -> Grid[{
    {Graphics[{Blue, Line[{{0, 0}, {1, 0}}]}, ImageSize -> {20, 20}],
     "Scope"},
    {Graphics[{Red, Line[{{0, 0}, {1, 0}}]}, ImageSize -> {20, 20}],
     "Other"}},
   Alignment -> {Left, Center}, Spacings -> 0],
 PlotStyle -> {Blue, Red}]

I can't take full (or any) credit.  This discussion came up a while ago and I happily scavenged these ideas from others.  The key is Grid[].  Play with it a while and it will grow on you :)

Paul


On Aug 3, 2011, at 6:06 AM, Andrew DeYoung wrote:

> Hi,
>
> I often use Mathematica 7 to display data, using ListPlot.  Since I
> end up creating plots containing lots of colored lines, it would be
> helpful if I could color the text that I display above my plots using
> PlotLabel.  Do you know if there is a way to do this without having to
> resort to the Plot Legends Package, which I sometimes find somewhat
> cumbersome to use (because I often end up having to spend a lot of
> time positioning the legend so that it does not cover my plot lines)?
>
> If you have time, I have plotted an example plot of mine here:
> http://www.andrew.cmu.edu/user/adeyoung/august2/august2.jpg
>
> In that plot, I have created the title using PlotLabel.  Specifically,
> I used the following Mathematica commands:
>
> ListPlot[
> {{energies1eq[[1]], fp*energies1eq[[7]]}\[Transpose], {20 +
> energies1md[[1]], fp*energies1md[[7]]}\[Transpose],
> {energies2eq[[1]], fp*energies2eq[[7]]}\[Transpose], {20 +
> energies2md[[1]], fp*energies2md[[7]]}\[Transpose],
> {energies3eq[[1]], fp*energies3eq[[7]]}\[Transpose], {20 +
> energies3md[[1]], fp*energies3md[[7]]}\[Transpose]},
> PlotRange->All,Joined->True,AxesLabel->{"t (ps)","(kcal/
> mol)"},PlotLabel->"Total Energy\nRed: Velocity-Verlet\nGreen: Leapfrog
> \nBlue: Accurate Velocity-Verlet\n",PlotStyle-
>> {Pink,Red,Green,Darker[Green],Cyan,Blue},ImageSize->imgSize]
>
> Do you know how to make my title that says, for example, "Red: ",
> actually red?
>
> Thank you very much for your time!
>
> Andrew DeYoung
> Carnegie Mellon University
>


Best,
Robert






Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Using colored text in PlotLabel "McHale, Paul" <Paul.McHale@excelitas.com> - 2011-10-23 10:31 +0000

csiph-web