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: [mg85147] Re: Text XY-size control in 2D graphics?
  • From: m.r at inbox.ru
  • Date: Wed, 30 Jan 2008 06:07:20 -0500 (EST)
  • References: <fnk3p2$l14$1@smc.vnet.net>

On Jan 28, 2:29=A0am, Gordon Robertson <agrobert... at telus.net> 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 =A0
> of stacked ACGT characters. Clearly I don't understand how to =A0
> position letters correctly, using settings for text size, position =A0
> and offset, and image size... but I imagine that it's possible to do =A0
> this. What's currently a bigger concern is that I need to control the =A0
> height of a character while keeping its width fixed, but for sizing =A0
> letters I see only FontSize[param]. I've checked the online =A0
> documentation, Options[Text], 'Mma Navigator', and Google, without =A0
> finding how to do this.
>
> Can anyone help by showing how to control Text character width and =A0
> height independently?
>
> ff = "Helvetica";
> Show[
> =A0 Graphics[
> =A0 =A0Text[Style["A", Green, Bold, FontSize -> Scaled[0.5], FontFamily -
> =A0> ff], {1,
> =A0 =A0 =A0 0}, {0, -1}]],
> =A0 Graphics[
> =A0 =A0Text[Style["C", Blue, Bold, FontSize -> Scaled[0.3], FontFamily -> =
=A0
> ff], {1,
> =A0 =A0 =A00}, {0, -3}]],
> =A0 Graphics[
> =A0 =A0Text[Style["G", RGBColor[1, 0.7, 0], Bold, FontSize -> Scaled[0.15]=
,
> =A0 =A0 =A0FontFamily -> ff], {1, 0}, {0, -4.5}]],
> =A0 Graphics[
> =A0 =A0Text[Style["T", Red, Bold, FontSize -> Scaled[0.05], FontFamily -> =
=A0
> ff], {1,
> =A0 =A0 =A00}, {0, -7}]],
> =A0 Frame -> True, FrameLabel -> {None, "bits"}, FrameTicks -> {{{0.5, =A0=

> 1, 1.5, 2}, None}, {{1}, None}},
> =A0 PlotRange -> {{0.5, 1.5}, {0, 2}}, AspectRatio -> 1, ImageSize -> 200
> =A0 ]
>
> G
> --
> Gordon Robertson
> Canada's Michael Smith Genome Sciences Centre
> Vancouver BC Canada

You can import from PDF to get the character outlines and then use
Inset or GeometricTransformation:

glyph[c_] := glyph[c] =
   ImportString[ExportString[
      Style[c, FontFamily -> "Helvetica",
       ShowStringCharacters -> False],
      "PDF"], "PDF"][[1, 1]];
f[c_, pos_, sz_, dir_: {}] :=
  Inset[Graphics[{dir, glyph[c]}, AspectRatio -> Full,
    PlotRangePadding -> 0],
   pos, Scaled@{0, 0}, sz];

Graphics[
 {f["A", {.5, 0}, {1, .25}],
  f["C", {.5, .25}, {1, 1.25}, Red],
  f["G", {1.5, 0}, {1, 1}, Blue],
  f["T", {1.5, 1}, {1, .5}]},
 Axes -> True, PlotRange -> {{0, 3}, {0, 2}}]

Maxim Rytin
m.r at inbox.ru


  • Prev by Date: Re: DataRange in ListPlot
  • Next by Date: Re: Filled Polar plots
  • Previous by thread: Re: Text XY-size control in 2D graphics?
  • Next by thread: Re: Text XY-size control in 2D graphics?