MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: A different font size for each line in PlotLabel

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80212] Re: [mg80195] A different font size for each line in PlotLabel
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Wed, 15 Aug 2007 04:09:31 -0400 (EDT)
  • References: <200708141114.HAA10017@smc.vnet.net>

tomfabtastic at hotmail.com wrote:

>Hello,
>
>Does anyone know how to use two fonts in a PlotLabel, where the title
>spans two lines.  For example:
>
>Needs["BarCharts`"]
>BarChart[{1, 2, 3}, PlotLabel -> "Title" <> "\n" <> "Subtitle"]
>  
>
There is no requirement that the rhs of PlotLabel be a string. So, 
instead of using strings and <>, you can use Column:

BarChart[{1, 2, 3}, PlotLabel -> Column[{"Title", "Subtitle"}, 
Alignment->Center]]

>The above produces a graph where the Title and Subtitle are on
>different lines and are the same FontSize.
>
>I would like "Title" to be FontSize -> 20 and "Subtitle" to be
>FontSize -> 10 (and to remain on different lines).
>  
>
So, add Style:

BarChart[{1, 2, 3}, PlotLabel->Column[{Style["Title", 20], 
Style["Subtitle",10]}, Alignment->Center]]

>If I use the below I get an error because "Title" is no longer a
>string.
>BarChart[{1, 2, 3}, PlotLabel -> StyleForm["Title", FontSize -> 20] <>
>"\n" <> "Subtitle"]
>
>But then if I use ToString, the FontSize goes back to default size:
>
>BarChart[{1, 2, 3}, PlotLabel -> ToString[StyleForm["Title", FontSize -
>  
>
>>20]] <> "\n" <> "Subtitle"]
>>    
>>
Note that in version 6, StyleForm is being superceded by Style. At any 
rate, ToString[ expr] by default converts to a string in OutputForm, and 
OutputForm does no retain any Style information. If you use 
ToString[expr, TraditionalForm] or ToString[expr, StandardForm], then 
the resulting string does retain Style information

BarChart[{1, 2, 3}, PlotLabel -> ToString[Style["Title", 20], 
TraditionalForm] <> "\n" <> "Subtitle"]

may also produce the output you are looking for.

Carl Woll
Wolfram Research

>
>Any suggestions would be greatly appreciated.
>
>Thanks,
>Tom
>
>  
>



  • Prev by Date: Re: Re: image opacity/image overlaying?
  • Next by Date: Re: RE: Re: question in mathematica
  • Previous by thread: A different font size for each line in PlotLabel
  • Next by thread: Re: A different font size for each line in PlotLabel