Make merged labels maintain the plot size by introducing x scaling

Tue, 30 Nov 2010 14:47:05 +0000

author
Andy Buckley <andy@insectnation.org>
date
Tue, 30 Nov 2010 14:47:05 +0000
changeset 93
451da9d4db08
parent 92
07ab27adb2ac
child 94
77808406c2d0

Make merged labels maintain the plot size by introducing x scaling

slhaplot file | annotate | diff | comparison | revisions
     1.1 --- a/slhaplot	Tue Nov 30 14:30:52 2010 +0000
     1.2 +++ b/slhaplot	Tue Nov 30 14:47:05 2010 +0000
     1.3 @@ -400,9 +400,12 @@
     1.4          xmin -= 1.0
     1.5          xmax += 1.0
     1.6      xdiff = xmax - xmin
     1.7 +    XWIDTH = 22.0
     1.8 +    def scalex(x):
     1.9 +        return x * XWIDTH/xdiff
    1.10  
    1.11 -    aspectratio = 0.7 #0.618
    1.12 -    ydiff = aspectratio * xdiff
    1.13 +    ASPECTRATIO = 0.7 #0.618
    1.14 +    ydiff = ASPECTRATIO * XWIDTH
    1.15      ymin = 0.0
    1.16      ymax = ymin + ydiff
    1.17      ## Get range of masses needed
    1.18 @@ -418,15 +421,15 @@
    1.19  
    1.20      ## Draw the plot boundary and y-ticks
    1.21      out += "  %% Frame\n"
    1.22 -    out += "  \\draw (%f,%f) rectangle (%f,%f);\n" % (xmin, ymin, xmax, ymax)
    1.23 +    out += "  \\draw (%f,%f) rectangle (%f,%f);\n" % (scalex(xmin), ymin, scalex(xmax), ymax)
    1.24      out += "  %% y-ticks\n"
    1.25      for mtick in xrange(0, int(maxdisplaymass) + 100, 100):
    1.26          ytick = mtick * yscale
    1.27 -        out += "  \\draw (%f,%f) node[left] {%d};\n" % (xmin, ytick, mtick)
    1.28 +        out += "  \\draw (%f,%f) node[left] {%d};\n" % (scalex(xmin), ytick, mtick)
    1.29          if mtick > 0 and mtick < maxdisplaymass:
    1.30              ## The 0.3 needs to be in the plot coords
    1.31 -            out += "  \\draw (%f,%f) -- (%f,%f);\n" % (xmin+0.3, ytick, xmin, ytick)
    1.32 -    out += "  \\draw (%f,%f) node[left,rotate=90] {Mass / GeV};\n" % (xmin-2.0, ymax)
    1.33 +            out += "  \\draw (%f,%f) -- (%f,%f);\n" % (scalex(xmin+0.3), ytick, scalex(xmin), ytick)
    1.34 +    out += "  \\draw (%f,%f) node[left,rotate=90] {Mass / GeV};\n" % (scalex(xmin-2.0), ymax)
    1.35  
    1.36      ## Decay arrows
    1.37      if DDETAILS:
    1.38 @@ -435,7 +438,7 @@
    1.39              for pidto, dd in sorted(todict.iteritems()):
    1.40                  out += "  %% decay_%d_%d\n" % (dd.pidfrom, dd.pidto)
    1.41                  out += "  \\draw[-stealth,thick,dashed,color=%s] (%f,%f) -- (%f,%f);\n" % \
    1.42 -                    (dd.color, dd.xyfrom[0], yscale*dd.xyfrom[1], dd.xyto[0], yscale*dd.xyto[1])
    1.43 +                    (dd.color, scalex(dd.xyfrom[0]), yscale*dd.xyfrom[1], scalex(dd.xyto[0]), yscale*dd.xyto[1])
    1.44  
    1.45      ## Draw mass lines
    1.46      if PDETAILS:
    1.47 @@ -444,7 +447,7 @@
    1.48              y = pdetail.mass*yscale
    1.49              out += "  %% pid%s\n" % str(pid)
    1.50              out += "  \\draw[color=%s,thick] (%f,%f) -- (%f,%f);\n" % \
    1.51 -                (pdetail.color, pdetail.xedges.left, y, pdetail.xedges.right, y)
    1.52 +                (pdetail.color, scalex(pdetail.xedges.left), y, scalex(pdetail.xedges.right), y)
    1.53  
    1.54      ## Particle labels
    1.55      if PLABELS:
    1.56 @@ -452,7 +455,7 @@
    1.57          for ld in PLABELS:
    1.58              anchors_pstricks_tikz = { "r" : "left", "l" : "right" }
    1.59              out += "  \\draw (%f,%f) node[%s] {\small %s};\n" % \
    1.60 -                (ld.xy[0], yscale*ld.xy[1], anchors_pstricks_tikz[ld.anchor], ld.texlabel)
    1.61 +                (scalex(ld.xy[0]), yscale*ld.xy[1], anchors_pstricks_tikz[ld.anchor], ld.texlabel)
    1.62  
    1.63      ## Write TikZ footer
    1.64      out += "\end{tikzpicture}\n\n"

mercurial