MathGroup Archive 2008

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

Search the Archive

Re: Text XY-size control in 2D graphics?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85170] Re: [mg85093] Text XY-size control in 2D graphics?
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Wed, 30 Jan 2008 06:19:11 -0500 (EST)
  • References: <200801280827.DAA21489@smc.vnet.net>

Gordon Robertson wrote:

>I would like to generate sequence logos (http://weblogo.berkeley.edu/ 
>examples.html) using v6's 2D graphics 'Text'.
>
>Below is an early and unsuccessful attempt to build a single column  
>of stacked ACGT characters. Clearly I don't understand how to  
>position letters correctly, using settings for text size, position  
>and offset, and image size... but I imagine that it's possible to do  
>this. What's currently a bigger concern is that I need to control the  
>height of a character while keeping its width fixed, but for sizing  
>letters I see only FontSize[param]. I've checked the online  
>documentation, Options[Text], 'Mma Navigator', and Google, without  
>finding how to do this.
>
>Can anyone help by showing how to control Text character width and  
>height independently?
>  
>
I don't know if it's possible to magnify letters in this way.

Instead, you could convert the letters to graphics, and then use 
AspectRatio to adjust the height and width. For example:

F = First@ImportString[ExportString[Style[HoldForm[F], FontFamily -> 
"Helvetica"], "PDF"], "PDF"]

Then,

Show[F, AspectRatio->4, ImageSize->15, PlotRange->Automatic]

will give you a vertically stretched F with width 15 points.

Carl

>ff = "Helvetica";
>Show[
>  Graphics[
>   Text[Style["A", Green, Bold, FontSize -> Scaled[0.5], FontFamily - 
> > ff], {1,
>      0}, {0, -1}]],
>  Graphics[
>   Text[Style["C", Blue, Bold, FontSize -> Scaled[0.3], FontFamily ->  
>ff], {1,
>     0}, {0, -3}]],
>  Graphics[
>   Text[Style["G", RGBColor[1, 0.7, 0], Bold, FontSize -> Scaled[0.15],
>     FontFamily -> ff], {1, 0}, {0, -4.5}]],
>  Graphics[
>   Text[Style["T", Red, Bold, FontSize -> Scaled[0.05], FontFamily ->  
>ff], {1,
>     0}, {0, -7}]],
>  Frame -> True, FrameLabel -> {None, "bits"}, FrameTicks -> {{{0.5,  
>1, 1.5, 2}, None}, {{1}, None}},
>  PlotRange -> {{0.5, 1.5}, {0, 2}}, AspectRatio -> 1, ImageSize -> 200
>  ]
>
>G
>--
>Gordon Robertson
>Canada's Michael Smith Genome Sciences Centre
>Vancouver BC Canada
>
>  
>



  • Prev by Date: Re: List complement operator
  • Next by Date: Re: front end commands
  • Previous by thread: Text XY-size control in 2D graphics?
  • Next by thread: Re: Text XY-size control in 2D graphics?