Skip navigation

On the heels of last evening’s release of Slopegraphs in Python post comes some minor tweaks:

  • Complete alignment control of labels & and values
  • Colors (for background, lines, labels & values) — I picked a random pattern from Adobe’s Kuler
  • A font change (to prove width calculations work)

…and a new example slopegraph:

As promised, the latest revisions are in github.

Some notes for aspiring Python/Cairo hackers:

  • RGB colors are 0-1 in Cairo, so divide your 0-255 values by 255 to get the corresponding Cairo value and make sure you’re doing float arithmetic in Python
  • It turns out simple Cairo font rendering (ie. non-Pango) does not interpret well in Illustrator from a Cairo PDF surface, so if you do plan on post-processing the slopegraphs, use a postscript/EPS surface:
    1. surface = cairo.PSSurface ("slopegraph.ps", width, height)
    2. surface.set_eps(True)

    (I’ll be incorporating an output option as this gets closer to 1.0)

  • If you do plan on using this at all, grab the Bitstream Vera Serif font (link goes to FontSquirrel, but you can find it almost everywhere as it’s free)

One Trackback/Pingback

  1. […] the previous installment, a foundation was laid for “parameterizing” fonts, colors and overall slopegraph size. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.