SlideShare ist ein Scribd-Unternehmen logo
1 von 68
Downloaden Sie, um offline zu lesen
NODEBOX FOR DATA VISUALIZATION
Lynn	
  Cherny	
  for	
  PyData	
  2013	
  
@arnicas	
  
www.ghostweather.com	
  
WHAT IS NODEBOX?
Nodebox.net	
  	
  
FLOCK EXAMPLE                                                   Take
                                                                     	
  that
                                                                             ,	
  ma
                                                                                     tplo   tlib	
  (
                                                                                                        ?!)	
  
h3p://www.cityinabo3le.org/nodebox/	
  




                                          Flock_example.py	
  
NODEBOX OPENGL
  from nodebox.graphics import *

  def draw(canvas):
    canvas.clear()
    nofill()                  Set	
  context	
  values	
  
    stroke(0, 0.25)
    strokewidth(1)              X,	
  Y,	
  width,	
  height	
   Local	
  override	
  of	
  context	
  
    rect( 50, 50, 50, 50)                                        values	
  
    rect(110, 50, 50, 50, stroke=Color(0), strokestyle=DASHED)
    rect(170, 50, 50, 50)

  canvas.run(draw)




                                                          0,0	
  in	
  lower	
  leB	
  by	
  default	
  (top	
  
                                                          leB	
  in	
  NB	
  1!)	
  
NODEBOX 1 IS A SMART IDE




                 Implicit	
  canvas,	
  draw,	
  etc.	
  
DOWNLOAD NODEBOX



           Mac	
  too,	
  I’ll	
             TentaQve	
  evidence	
  
             demo	
                             of	
  linux	
  too	
  




          http://nodebox.net/download/	
  
GENERATIVE ART




            JusQn	
  D	
  on	
  flickr.	
  
            	
  
HIGH QUALITY GRAPHIC OUTPUT




                TODO.TO.IT	
  
LIBRARIES IN NODEBOX 1 (MAC OSX)




      Note:	
  these	
  libraries	
  must	
  be	
  put	
  in	
  ~/Library/Application	
  
      Support/Nodebox	
  to	
  be	
  imported.	
  All	
  the	
  libs	
  live	
  here.	
  
IMAGE TOOLS
NETWORK TOOLS (SOPHISTICATED!)
COLOR TOOLS, SVG
GRIDS
L-SYSTEMS, ANTS, BOIDS…
DEMOS IN NODEBOX 1
If	
  you	
  do	
  data	
  visualization,	
  but	
  not	
  “art,”	
  
WHY WOULD YOU NEED THIS TOOL?
SKETCHES IN CODE




                   Examples	
  from	
  
                   Processing	
  sketches	
  
                   by	
  JanWillem	
  Tulp	
  
“Ghost	
  CounQes,”	
  by	
  @JanWillemTulp	
  
UNUSUAL GRAPH TYPES




        Slopegraph	
  from	
  Juice	
  Analytics,	
  code	
  for	
  NB	
  1	
  
TOOL CREATION

  My	
  sparklines	
  generator	
  in	
  
  NB	
  OGL	
  




 Example	
  sparks.py	
  in	
  NB	
  OGL	
  
NODEBOX 1 “GUI”




         Example	
  bars_with_goals.py	
  for	
  NB1	
  
CLOSEST SIMILAR TOOLS
 Drawbot	
  (Preceded	
  and	
  inspired	
  Nodebox,	
  
      	
  MacOSX	
  only)	
  
 Shoebot	
  (MacOSX),	
  with	
  Spryte	
  for	
  Windows	
  
      	
  (some	
  examples	
  run	
  unchanged	
  in	
  NB1!)	
  
 Pythonista	
  on	
  Ipad!	
  	
  
 	
  
 Processing	
  (cross	
  platform,	
  includes	
  .js	
  port)	
  
    	
  (Processing.py	
  by	
  jpheinberg	
  is	
  jython-­‐based.)	
  
PROCESSING LOOKS LIKE JAVA L



       Plus,	
  obviously,	
  I	
  want	
  Python	
  libs	
  




                    h3p://openprocessing.org/sketch/8941	
  
Very,	
  very	
  short	
  intro	
  to	
  the	
  concepts…	
  
DRAWING BASICS
NODEBOX 1 PRIMITIVES




  Most	
  of	
  them	
  in	
  NB	
  OGL	
  
  Note:	
  no	
  triangle()	
  as	
  in	
  Nodebox	
  OGL;	
  “oval”	
  instead	
  of	
  “ellipse”	
  as	
  in	
  OGL	
  
SHAPE PRIMITIVES IN NODEBOX OGL




            NOTE:	
  ellipse()	
  not	
  oval()	
  as	
  in	
  NB1	
  
THE DRAW() LOOP
 Nodebox	
  1	
  can	
  be	
  used	
  for	
  simple	
  static	
  image	
  
 without	
  animation	
  –	
  no	
  canvas	
  declaration	
  	
  or	
  
 draw	
  loop	
  needed.	
  	
  (Use	
  speed(<fps>)	
  to	
  turn	
  on	
  
 the	
  animation.)	
  
 	
  
 Nodebox	
  OGL	
  	
  always	
  runs	
  an	
  animation	
  loop	
  in	
  
 a	
  draw	
  function	
  (you	
  can	
  exit	
  out	
  with	
  a	
  return	
  
 after	
  canvas.frame==1	
  in	
  “draw”	
  if	
  you	
  want)	
  
      	
  	
   mycanvas = Canvas(width=600, height=480)
              mycanvas.fps = 20
              mycanvas.run(draw=draw,setup=setup)
DRAWING CONTEXT CHANGES
        State	
  context	
  changers:	
  
        	
  
        colormode(), fill(), stroke(), strokewidth(),
 	
     nofill(), nostroke()
        font(), fontsize()
        transform(), translate(), rotate(), scale(), skew()
        	
  
        	
  
        Temporary	
  state	
  changes:	
  	
  
        	
  
                  	
  push()
                      fill(0)
                      translate(200,200)
                      pop()
        	
  
NOTICE THE CONTEXT AGAIN…
from nodebox.graphics import *

def draw(canvas):
  canvas.clear()
  nofill()                  Set	
  context	
  values	
  
  stroke(0, 0.25)
  strokewidth(1)              X,	
  Y,	
  width,	
  height	
   Local	
  override	
  of	
  context	
  
  rect( 50, 50, 50, 50)                                        values	
  
  rect(110, 50, 50, 50, stroke=Color(0), strokestyle=DASHED)
  rect(170, 50, 50, 50)

canvas.run(draw)
LEARNING THE “REST”
 §  Examples	
  with	
  both	
  NB	
  1	
  and	
  NB	
  OGL	
  
     distribs:	
  commented	
  and	
  by	
  topic	
  
 §  Tutorials	
  on	
  the	
  NB	
  1	
  site	
  	
  
 §  The	
  extensive	
  intro	
  page	
  for	
  NB	
  OGL	
  (that	
  
     builds	
  off	
  NB1’s	
  api	
  background)	
  
Getting	
  Real(ly	
  dirty	
  and	
  sketchy)	
  
MY TOY EXAMPLES
FICTION INVESTIGATION…
 Shane	
  Bergsma’s	
  db	
  of	
  noun	
  gender	
  (based	
  on	
  
 Google	
  news	
  crawling):	
  [see	
  refs]	
  
            	
        	
     	
  “word	
  male	
  female	
  neutral	
  plural”,	
  e.g.:	
  
            	
        	
     	
  publication 	
  93	
  	
  20	
  	
  3152	
  110	
  
     	
  
     1.            Load	
  Shane’s	
  db	
  into	
  redis	
  
     2.            Convert	
  books	
  to	
  txt	
  (blank	
  line	
  bw	
  paragraphs)	
  
     3.            	
  Extract	
  nouns	
  with	
  pattern.py	
  	
  
     4.            Code	
  each	
  with	
  tuple	
  (m,	
  f,	
  n)	
  &	
  %’s	
  	
  
     5.            Write	
  out	
  as	
  csv	
  for	
  use	
  in	
  Nodebox	
  scripts	
  
COORDINATES IN COLOR AND 3-SPACE
                    Neutral	
  




         Male	
                   Female	
  
FOOTNOTE: HSV IN THE BLUE-RED
RANGE / WITH DARKNESS




  Code	
  borrowed	
  from	
  an	
  example	
  on	
  StackOverflow	
  –	
  tuned	
  to	
  get	
  only	
  hue	
  from	
  
  blue	
  to	
  red	
  from	
  complete	
  HSV	
  range	
  
GET CARTESIAN X, Y COORD FROM A
TUPLE
    def to_cart(triple):
          (m, f, n) = triple
          x = ( f + n / 2.0)
          y = math.sqrt(3) * n / 2.0
          return x, y




             Code	
  in	
  my	
  common.py	
  file	
  
INTERPOLATION
 You	
  often	
  need	
  to	
  map	
  from	
  a	
  data	
  range	
  to	
  another	
  range	
  
 (of	
  pixels,	
  or	
  color	
  points…).	
  Mapping	
  my	
  X	
  and	
  Y	
  to	
  colors:	
  
 	
  
      from scipy.interpolate import interp1d
      hue_scale = interp1d([0,1],[.67,1])
      	
  
      For	
  pythonic	
  hsv	
  color	
  and	
  then	
  nodebox	
  rgb:	
  
      	
  
      hsv = (hue_scale(x)[0], 1, 1-y[0])
      rgb = Color(colorsys.hsv_to_rgb(*hsv))



                                                      I	
  am	
  flipping	
  
                                                      the	
  V!	
  
Triangle_hist_uniq.py	
  
EVENTS : LAYERS, MOUSE, KEYS
 Layers	
  in	
  NB	
  OGL	
  are	
  one	
  good	
  way	
  you	
  might	
  
 handle	
  “mouseover”	
  functionality	
  
                Layers	
  have	
  their	
  own	
  draw()	
  functionality,	
  and	
  the	
  
                canvas	
  knows	
  that	
  layer	
  is	
  in	
  focus	
  (under	
  the	
  mouse,	
  via	
  
                canvas.focus)	
  
                	
  
 Mouse	
  events	
  are	
  also	
  handled	
  nicely	
  by	
  
 canvas.mouse	
  –	
  mouse.x,	
  mouse.y,	
  etc.	
  are	
  
 available	
  
 	
  
 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  See	
  my	
  example	
  triangle_layers.py	
  
layers_intro.py	
  
MOUSE & KEYBOARD EVENTS
                                                        mouse	
  =	
  canvas.mouse	
  
                                                        mouse.x	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Horizontal	
  position.	
  
                                                        mouse.y	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Vertical	
  position.	
  
NB	
  OGL:	
  h3p://www.cityinabo3le.org/nodebox/	
  




                                                        mouse.relative_x	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Relative	
  (0.0-­‐1.0)	
  to	
  Canvas.width.	
  
                                                        mouse.relative_y	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Relative	
  (0.0-­‐1.0)	
  to	
  Canvas.height.	
  
                                                        mouse.dx	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Drag	
  distance	
  from	
  previous	
  x.	
  
                                                        mouse.dy	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Drag	
  distance	
  from	
  previous	
  y.	
  
                                                        mouse.pressed	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  if	
  the	
  mouse	
  button	
  is	
  pressed.	
  
                                                        mouse.dragged	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  if	
  the	
  mouse	
  is	
  dragged.	
  
                                                        mouse.cursor	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  DEFAULT,	
  CROSS,	
  HAND,	
  HIDDEN,	
  TEXT,	
  WAIT	
  
                                                        mouse.button	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  LEFT,	
  RIGHT,	
  MIDDLE	
  
                                                        mouse.modifiers	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  List	
  of:	
  CTRL,	
  SHIFT,	
  OPTION	
  
                                                        keys	
  =	
  canvas.keys	
  
                                                        keys[]	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  All	
  keys	
  pressed	
  (SHIFT	
  +	
  "a"	
  =>	
  [SHIFT,	
  "a"]).	
  
                                                        keys.char	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Last	
  key	
  pressed	
  (SHIFT	
  +	
  "a"	
  =>	
  "A").	
  
                                                        keys.code	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  Last	
  key	
  pressed	
  (SHIFT	
  +	
  "a"	
  =>	
  "a").	
  
                                                        keys.modifiers	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  List	
  of	
  modifier	
  keys	
  (CTRL,	
  SHIFT,	
  OPTION).	
  
                                                        keys.pressed	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  if	
  a	
  key	
  is	
  pressed	
  on	
  the	
  keyboard.	
  
LAYERS GOT EVENTS TOO
                                                        layer.enabled	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  =>	
  will	
  receive	
  events.	
  
                                                        layer.pressed	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  =>	
  mouse	
  pressed	
  on	
  layer.	
  
NB	
  OGL:	
  h3p://www.cityinabo3le.org/nodebox/	
  




                                                        layer.dragged	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  =>	
  mouse	
  dragged	
  on	
  layer.	
  
                                                        layer.focus	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  True	
  =>	
  mouse	
  hovering	
  over	
  layer.	
  
                                                        layer.on_mouse_enter(mouse)	
  
                                                        layer.on_mouse_leave(mouse)	
  
                                                        layer.on_mouse_motion(mouse)	
  
                                                        layer.on_mouse_press(mouse)	
  
                                                        layer.on_mouse_release(mouse)	
  
                                                        layer.on_mouse_drag(mouse)	
  
                                                        layer.on_mouse_scroll(mouse)	
  
                                                        layer.on_key_press(keys)	
  
                                                        layer.on_key_release(keys)	
  
MOUSEOVER




            	
  	
  Triangle_layers.py	
  
A FAILED EXPERIMENT CAN STILL BE
FUN… ADDING ANIMATION.
Angels	
  &	
  Demons	
  (Brown)	
  


Twilight	
  (Meyer)	
  
                                                                            “jade”	
  


Pride	
  &	
  Prejudice	
  (Austen)	
  


The	
  Secret	
  Agent	
  (Conrad)	
  	
  




                                             	
  triangle_bar_uniq.py	
  
GETTING BLUNTER… 2 ON ONE:
 Doesn’t	
  show	
  much…	
  
 sigh.	
  
JUST GET EVEN BLUNTER…
Centroid	
  of	
  each…	
  a	
  li3le	
  
more	
  revealing	
  maybe?	
  
Definitely	
  not	
  for	
  publicaQon!	
  
THERE CAN BE VALUE IN “MISTAKES”
WHEN VISUALIZING DATA AT PIXEL LEVEL




            Thanks	
  to	
  MarQn	
  Wa3enberg	
  
            and	
  Fernanda	
  Viegas	
  for	
  this	
  
            observaQon…	
  
A MORE INTERESTING MISTAKE…
   If	
  you	
  don’t	
  filter	
  out	
  duplicate	
  menQons	
  of	
  the	
  same	
  
   noun….	
  
Twilight	
     Angels	
  &	
  Demons	
  
Triangle_hist_notuniq.py	
  
Twilight	
      Angels	
  &	
  Demons	
  
                            (uniqued)	
     (uniqued)	
  
Triangle_hist_uniq.py	
  
RATIO OF NOUNS TO UNIQUE NOUNS
(AS EXPECTED NOW)

                             Unique	
   Nouns/	
             Nouns/
                   Nouns	
                         Words	
  
  	
  	
                     Nouns	
   Unique	
              Words	
  
     Angels	
  &	
  
                     19546	
     2842	
     6.9	
     151610	
     7.8	
  
       Demons	
  
   Twilight	
       18252	
      1943	
     9.4	
     121205	
     6.6	
  
Twilight	
  (most	
  repeated)	
                  Angels	
  &	
  Demons	
  (most	
  repeated)	
  




                                     Line_freqs.py	
  
HOOKING UP OTHER PYTHON LIBS
 1.  Load	
  a	
  book	
  into	
  redis	
  by	
  line	
  #	
  
 2.  Plot	
  dialog	
  vs.	
  exposition	
  in	
  a	
  simple	
  colored	
  
      bar	
  
 3.  Use	
  the	
  redis	
  db	
  to	
  see	
  what’s	
  what	
  in	
  the	
  
      book	
  on	
  rollover!	
  
 	
  
 Simple,	
  and	
  very	
  fast!	
  
DIALOG TO EXPOSITION…
 Twilight	
  	
                                                                                       Angels	
  &	
  Demons	
  
                    Secret	
  Agent	
        Pride	
  &	
  Prejudice	
     Moby	
  Dick	
  
 (Meyer)	
                                                                                            (Brown)	
  




                                                                           Para	
  groups:	
  7	
  

                                          Quote_bar_nodb.py	
  
Phew!	
  That	
  was	
  a	
  lot	
  of	
  stuff.	
  
WRAP UP…
WHY OR WHY NOT NODEBOX?
 Advantages              	
  	
  
 §  Data	
  as	
  “art”	
  –	
  not	
  supported	
  by	
  Matplotlib	
  (or	
  
     future	
  ggplot2	
  ports	
  to	
  python)	
  
 §  Data	
  “sketching”	
  –	
  	
  speedy	
  unstructured	
  pics	
  
 §  Animation	
  is	
  basic	
  
 §  Events	
  come	
  along	
  too	
  
 §  You	
  get	
  to	
  write	
  in	
  Python	
  (unlike	
  w/	
  Processing)	
  
 §  So	
  you	
  can	
  use	
  other	
  Python	
  libs	
  

 	
  
BUT…
 §  No	
  3d	
  (unlike	
  matplotlib)	
  
 §  PDF	
  or	
  SVG	
  Export	
  are	
  required	
  for	
  good	
  print/reuse	
  (available	
  in	
  
      NB	
  1,	
  not	
  in	
  NB	
  OGL	
  yet)	
  
 §  No	
  web	
  embedding	
  /	
  js	
  version	
  (unlike	
  processing.js)	
  
 §  Can’t	
  use	
  with	
  IPython	
  notebook	
  (yet)	
  
 §  Challenge	
  of	
  other	
  python	
  libs	
  with	
  NB	
  1	
  -­‐	
  sad	
  PYTHONPATH	
  
      problem	
  in	
  Nodebox	
  1	
  (see	
  appendix	
  for	
  tips)	
  
 §  Authors	
  in	
  Leuven	
  more	
  focused	
  on	
  NB	
  3/Pattern.py	
  than	
  on	
  NB1	
  /	
  
      OGL	
  versions.	
  
      	
   	
   	
   	
  Can	
  we	
  invigorate	
  Nobebox	
  OpenGL?	
  
 	
  
 §  A	
  general	
  lack	
  of	
  code	
  examples	
  to	
  draw	
  from…	
  hopefully	
  mine	
  will	
  
      help!	
  
THAT’S IT - A BIG THANKS!
@deepfoo	
  for	
  the	
  reminder	
  of	
  Nodebox1,	
  
Tom	
  De	
  Smedt	
  and	
  Frederik	
  De	
  Bleser	
  for	
  
email	
  help,	
  @minrk	
  for	
  help,	
  @jsundram	
  for	
  
code	
  cleanup	
  advice	
  (not	
  all	
  of	
  which	
  I	
  took),	
  
@pwang	
  and	
  #PyData	
  for	
  having	
  me	
  
Find	
  me	
  @arnicas,	
  www.ghostweather.com	
  
blog	
  

GET THE CODE FILES HERE!
PDF OF THESE SLIDES HERE.

   Apologies	
  for	
  the	
  import	
  *	
  and	
  the	
  globals…	
  	
  I	
  was	
  following	
  some	
  
   suggesQons	
  in	
  the	
  demos	
  I	
  looked	
  at	
  which	
  may	
  not	
  have	
  been	
  ideal.	
  
REFERENCES
§  JanWillem	
  Tulp	
  Ghost	
  Counties	
  images:
    	
  http://www.flickr.com/photos/janwillemtulp/sets/72157626612248205/	
  
§  Code	
  for	
  ternary	
  plots	
  in	
  python	
  and	
  excel:	
  
    http://sourceforge.net/projects/wxternary/	
  and	
  Will	
  Vaughn’s	
  at	
  
    http://wvaughan.org/ternaryplots.html	
  
§  Nodebox	
  flickr	
  gallery	
  
§  Running	
  Nodebox	
  1	
  from	
  command	
  line:	
  
    http://nodebox.net/code/index.php/Console	
  
§  Pattern.py	
  by	
  Tom	
  de	
  Smedt	
  (a	
  Nodebox	
  original	
  author)	
  
§  Nodebox	
  authors	
  Tom	
  De	
  Smedt	
  and	
  Frederik	
  De	
  Bleser	
  in	
  Belgium	
  
§  Shane	
  Bergsma	
  and	
  Dekang	
  Lin,	
  “Bootstrapping	
  Path-­‐Based	
  Pronoun	
  
    Resolution,”	
  In	
  Proceedings	
  of	
  the	
  Conference	
  on	
  Computational	
  
    Lingustics	
  /	
  Association	
  for	
  Computational	
  Linguistics	
  (COLING/
    ACL-­‐06),	
  Sydney,	
  Australia,	
  July	
  17-­‐21,	
  2006.	
  (page	
  w/	
  db)	
  
APPENDIX: NODEBOX 1’S IMPORT PATH

 Custom	
  path,	
  includes	
  its	
  own	
  python	
  (64	
  bit)…	
  so….	
  
      –  You	
  can	
  install	
  your	
  packages	
  into	
  NodeBox’s	
  path,	
  ie.,	
  ~/
         Library/Application	
  Support/NodeBox/	
  —	
  meaning	
  that	
  you	
  
         can	
  use	
  them	
  from	
  NodeBox,	
  but	
  not	
  from	
  other	
  scripts…	
  
      –  You	
  can	
  import	
  sys	
  in	
  your	
  NodeBox	
  code	
  and	
  manually	
  modify	
  
         the	
  sys.path	
  value	
  to	
  add	
  your	
  existing	
  packages…	
  
      –  You	
  can	
  install	
  packages	
  into	
  your	
  system	
  site-­‐packages	
  
         directory,	
  and	
  sym-­‐link	
  them	
  from	
  NodeBox’s	
  directory…	
  
      –  You	
  can	
  make	
  NodeBox	
  use	
  your	
  system	
  packages	
  instead	
  of	
  
         it’s	
  own	
  by	
  sym-­‐linking	
  ~/Library/Application	
  Support/
         NodeBox	
  to	
  your	
  site-­‐packages	
  directory	
  of	
  choice	
  (ex.,	
  /
         Library/Python/2.5/site-­‐packages)	
  
      –  Some	
  flavor	
  of	
  above	
  plus	
  VIRTUALENV	
  


 Tips	
  from	
  h3p://www.eriksmar3.com/blog/archives/747	
  
 Thread	
  here	
  too:	
  h3p://nodebox.net/code/index.php/shared_2008-­‐09-­‐04-­‐01-­‐42-­‐29	
  
APPENDIX: NODEBOX1 AT COMMAND
LINE…
 §  Instructions	
  and	
  samples	
  here:	
  
     http://nodebox.net/code/index.php/Console	
  
 §  Best	
  to	
  use	
  a	
  virtualenv	
  again	
  
THE NODEBOX “FAMILY”
Nodebox	
  1	
  
                            Platform	
  &	
  “style”	
  
                            Mac	
  OSX	
  only	
  (kind	
  of	
  
                                                                        Status	
  
                                                                        No	
  longer	
  in	
  dev,	
  spotty	
  
                                                                                                                         URLs	
  
                                                                                                                         Mac	
  OSX	
  Lion	
  file:	
  
                            Lion)	
  –	
  write	
  python	
  code	
     archiving	
  online	
                            https://secure.nodebox.net/
	
  (the	
  original)	
                                                                                                  downloads/
                            in	
  a	
  simple	
  IDE	
  
                                                                                                                         NodeBox-­‐1.9.7rc1.zip	
  
                                                                                                                         Home:	
  
                                                                                                                         http://nodebox.net/code/
                                                                                                                         index.php/Home	
  
                                                                                                                         Github	
  copy	
  of	
  svn	
  source:	
  
                                                                                                                         https://github.com/nodebox/
                                                                                                                         nodebox-­‐pyobjc	
  
                                                                                                                         	
  


Nodebox	
  2	
  	
          Mac	
  OSX	
  –	
  python	
  visual	
       GONE!	
  	
  Apparently	
  was	
                 Home:	
  
(the	
  disappeared)	
      programming	
  “blocks”	
                   slow	
  and	
  confusing?	
                      http://Beta.nodebox.net	
  
Nodebox	
  3	
  	
          Mac	
  and	
  Windows	
  –	
  no	
          Not	
  so	
  interesting	
  to	
  me:	
  I	
     Home:	
  
                            IDE,	
  no	
  python	
  exposed,	
          want	
  to	
  write	
  python	
  	
              http://nodebox.net/node/	
  
(the	
  current	
                                                                                                        	
  
beta)	
                     all	
  visual	
  programming?	
             code.	
  

Nodebox	
                   Mac	
  and	
  Windows	
  –	
  write	
       Not	
  up	
  to	
  date	
  with	
                Home:	
  
                            plain	
  python	
  code	
                   Nodebox	
  1	
  yet	
  (e.g.,	
  lack	
          http://www.cityinabottle.org/
OpenGL	
  (the	
                                                                                                         nodebox/	
  	
  
incomplete)	
                                                           of	
  libraries,	
  lack	
  of	
  
                                                                                                                         Github	
  code:	
  
                                                                        functionality;	
  not	
  so	
  well	
  
                                                                                                                         https://github.com/nodebox/
                                                                        documented);	
  can’t	
  run	
  in	
             nodebox-­‐opengl	
  
                                                                        IPython	
  notebook	
  due	
  to	
               	
  
                                                                        probable	
  multithreading	
                     	
  
                                                                        issue(s)	
  

Weitere ähnliche Inhalte

Was ist angesagt?

Gentlest Introduction to Tensorflow
Gentlest Introduction to TensorflowGentlest Introduction to Tensorflow
Gentlest Introduction to TensorflowKhor SoonHin
 
CS 354 Graphics Math
CS 354 Graphics MathCS 354 Graphics Math
CS 354 Graphics MathMark Kilgard
 
CS 354 Texture Mapping
CS 354 Texture MappingCS 354 Texture Mapping
CS 354 Texture MappingMark Kilgard
 
Shadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics HardwareShadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics Hardwarestefan_b
 
2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy
2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy
2013-1 Machine Learning Lecture 02 - Andrew Moore: EntropyDongseo University
 
[shaderx5] 3.2 Selective Supersampling
[shaderx5] 3.2 Selective Supersampling[shaderx5] 3.2 Selective Supersampling
[shaderx5] 3.2 Selective Supersampling종빈 오
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programmingMassimiliano Dessì
 
MLIP - Chapter 4 - Image classification and CNNs
MLIP - Chapter 4 - Image classification and CNNsMLIP - Chapter 4 - Image classification and CNNs
MLIP - Chapter 4 - Image classification and CNNsCharles Deledalle
 
Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Khor SoonHin
 
Accelerometers to Augmented Reality
Accelerometers to Augmented RealityAccelerometers to Augmented Reality
Accelerometers to Augmented Realityjblocksom
 
CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationMark Kilgard
 
CS 354 Acceleration Structures
CS 354 Acceleration StructuresCS 354 Acceleration Structures
CS 354 Acceleration StructuresMark Kilgard
 
TensorFlow in Practice
TensorFlow in PracticeTensorFlow in Practice
TensorFlow in Practiceindico data
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel UpdatingMark Kilgard
 
Class 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation RulesClass 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation RulesDavid Evans
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics PipelineMark Kilgard
 
CS 354 Blending, Compositing, Anti-aliasing
CS 354 Blending, Compositing, Anti-aliasingCS 354 Blending, Compositing, Anti-aliasing
CS 354 Blending, Compositing, Anti-aliasingMark Kilgard
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviEnthought, Inc.
 

Was ist angesagt? (19)

Gentlest Introduction to Tensorflow
Gentlest Introduction to TensorflowGentlest Introduction to Tensorflow
Gentlest Introduction to Tensorflow
 
CS 354 Graphics Math
CS 354 Graphics MathCS 354 Graphics Math
CS 354 Graphics Math
 
CS 354 Texture Mapping
CS 354 Texture MappingCS 354 Texture Mapping
CS 354 Texture Mapping
 
Shadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics HardwareShadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics Hardware
 
2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy
2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy
2013-1 Machine Learning Lecture 02 - Andrew Moore: Entropy
 
[shaderx5] 3.2 Selective Supersampling
[shaderx5] 3.2 Selective Supersampling[shaderx5] 3.2 Selective Supersampling
[shaderx5] 3.2 Selective Supersampling
 
Why we cannot ignore functional programming
Why we cannot ignore functional programmingWhy we cannot ignore functional programming
Why we cannot ignore functional programming
 
MLIP - Chapter 4 - Image classification and CNNs
MLIP - Chapter 4 - Image classification and CNNsMLIP - Chapter 4 - Image classification and CNNs
MLIP - Chapter 4 - Image classification and CNNs
 
Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2Gentlest Introduction to Tensorflow - Part 2
Gentlest Introduction to Tensorflow - Part 2
 
Dip3
Dip3Dip3
Dip3
 
Accelerometers to Augmented Reality
Accelerometers to Augmented RealityAccelerometers to Augmented Reality
Accelerometers to Augmented Reality
 
CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and Representation
 
CS 354 Acceleration Structures
CS 354 Acceleration StructuresCS 354 Acceleration Structures
CS 354 Acceleration Structures
 
TensorFlow in Practice
TensorFlow in PracticeTensorFlow in Practice
TensorFlow in Practice
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
Class 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation RulesClass 22: Stateful Evaluation Rules
Class 22: Stateful Evaluation Rules
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics Pipeline
 
CS 354 Blending, Compositing, Anti-aliasing
CS 354 Blending, Compositing, Anti-aliasingCS 354 Blending, Compositing, Anti-aliasing
CS 354 Blending, Compositing, Anti-aliasing
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
 

Andere mochten auch

Mining Someone Else's Magic World: Dwarf Fortress Story Generation
Mining Someone Else's Magic World: Dwarf Fortress Story GenerationMining Someone Else's Magic World: Dwarf Fortress Story Generation
Mining Someone Else's Magic World: Dwarf Fortress Story GenerationLynn Cherny
 
Visualizing Networks
Visualizing NetworksVisualizing Networks
Visualizing NetworksLynn Cherny
 
Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)
Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)
Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)Lynn Cherny
 
Things I Think Are Awesome (Eyeo 2016 Talk)
Things I Think Are Awesome (Eyeo 2016 Talk)Things I Think Are Awesome (Eyeo 2016 Talk)
Things I Think Are Awesome (Eyeo 2016 Talk)Lynn Cherny
 
Solving graph problems using networkX
Solving graph problems using networkXSolving graph problems using networkX
Solving graph problems using networkXKrishna Sangeeth KS
 

Andere mochten auch (6)

Mining Someone Else's Magic World: Dwarf Fortress Story Generation
Mining Someone Else's Magic World: Dwarf Fortress Story GenerationMining Someone Else's Magic World: Dwarf Fortress Story Generation
Mining Someone Else's Magic World: Dwarf Fortress Story Generation
 
Am
AmAm
Am
 
Visualizing Networks
Visualizing NetworksVisualizing Networks
Visualizing Networks
 
Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)
Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)
Bestseller Analysis: Visualization Fiction (for PyData Boston 2013)
 
Things I Think Are Awesome (Eyeo 2016 Talk)
Things I Think Are Awesome (Eyeo 2016 Talk)Things I Think Are Awesome (Eyeo 2016 Talk)
Things I Think Are Awesome (Eyeo 2016 Talk)
 
Solving graph problems using networkX
Solving graph problems using networkXSolving graph problems using networkX
Solving graph problems using networkX
 

Ähnlich wie Nodebox for Data Visualization

HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebRobin Hawkes
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Wen-Wei Liao
 
CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9fungfung Chen
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
Volume Rendering in Unity3D
Volume Rendering in Unity3DVolume Rendering in Unity3D
Volume Rendering in Unity3DMatias Lavik
 
Trident International Graphics Workshop 2014 5/5
Trident International Graphics Workshop 2014 5/5Trident International Graphics Workshop 2014 5/5
Trident International Graphics Workshop 2014 5/5Takao Wada
 
DojoX GFX Session Eugene Lazutkin SVG Open 2007
DojoX GFX Session Eugene Lazutkin SVG Open 2007DojoX GFX Session Eugene Lazutkin SVG Open 2007
DojoX GFX Session Eugene Lazutkin SVG Open 2007Eugene Lazutkin
 
Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)TongXu520
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10fungfung Chen
 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your BrowserOswald Campesato
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your BrowserOswald Campesato
 
Processing presentation
Processing presentationProcessing presentation
Processing presentationrngtng
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Bryan O'Sullivan
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsOswald Campesato
 

Ähnlich wie Nodebox for Data Visualization (20)

SA09 Realtime education
SA09 Realtime educationSA09 Realtime education
SA09 Realtime education
 
HTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the WebHTML5 Canvas - The Future of Graphics on the Web
HTML5 Canvas - The Future of Graphics on the Web
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012
 
CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9CG OpenGL surface detection+illumination+rendering models-course 9
CG OpenGL surface detection+illumination+rendering models-course 9
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
Online Signal Processing Assignment Help
Online Signal Processing Assignment HelpOnline Signal Processing Assignment Help
Online Signal Processing Assignment Help
 
Volume Rendering in Unity3D
Volume Rendering in Unity3DVolume Rendering in Unity3D
Volume Rendering in Unity3D
 
Trident International Graphics Workshop 2014 5/5
Trident International Graphics Workshop 2014 5/5Trident International Graphics Workshop 2014 5/5
Trident International Graphics Workshop 2014 5/5
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 
P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218
 
DojoX GFX Session Eugene Lazutkin SVG Open 2007
DojoX GFX Session Eugene Lazutkin SVG Open 2007DojoX GFX Session Eugene Lazutkin SVG Open 2007
DojoX GFX Session Eugene Lazutkin SVG Open 2007
 
Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)
 
CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10CG OpenGL Shadows + Light + Texture -course 10
CG OpenGL Shadows + Light + Texture -course 10
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your Browser
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
 
Processing presentation
Processing presentationProcessing presentation
Processing presentation
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.js
 

Mehr von Lynn Cherny

COCO's Memory Palace: A Strange Fantasia
COCO's Memory Palace: A Strange FantasiaCOCO's Memory Palace: A Strange Fantasia
COCO's Memory Palace: A Strange FantasiaLynn Cherny
 
The Bones of a Bestseller: Visualizing Fiction
The Bones of a Bestseller: Visualizing FictionThe Bones of a Bestseller: Visualizing Fiction
The Bones of a Bestseller: Visualizing FictionLynn Cherny
 
Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)Lynn Cherny
 
A Fast and Dirty Intro to NetworkX (and D3)
A Fast and Dirty Intro to NetworkX (and D3)A Fast and Dirty Intro to NetworkX (and D3)
A Fast and Dirty Intro to NetworkX (and D3)Lynn Cherny
 
Simplifying Social Network Diagrams
Simplifying Social Network Diagrams Simplifying Social Network Diagrams
Simplifying Social Network Diagrams Lynn Cherny
 
Design For Online Community: Beyond the Hype
Design For Online Community: Beyond the HypeDesign For Online Community: Beyond the Hype
Design For Online Community: Beyond the HypeLynn Cherny
 

Mehr von Lynn Cherny (6)

COCO's Memory Palace: A Strange Fantasia
COCO's Memory Palace: A Strange FantasiaCOCO's Memory Palace: A Strange Fantasia
COCO's Memory Palace: A Strange Fantasia
 
The Bones of a Bestseller: Visualizing Fiction
The Bones of a Bestseller: Visualizing FictionThe Bones of a Bestseller: Visualizing Fiction
The Bones of a Bestseller: Visualizing Fiction
 
Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)
 
A Fast and Dirty Intro to NetworkX (and D3)
A Fast and Dirty Intro to NetworkX (and D3)A Fast and Dirty Intro to NetworkX (and D3)
A Fast and Dirty Intro to NetworkX (and D3)
 
Simplifying Social Network Diagrams
Simplifying Social Network Diagrams Simplifying Social Network Diagrams
Simplifying Social Network Diagrams
 
Design For Online Community: Beyond the Hype
Design For Online Community: Beyond the HypeDesign For Online Community: Beyond the Hype
Design For Online Community: Beyond the Hype
 

Nodebox for Data Visualization

  • 1. NODEBOX FOR DATA VISUALIZATION Lynn  Cherny  for  PyData  2013   @arnicas   www.ghostweather.com  
  • 4. FLOCK EXAMPLE Take  that ,  ma tplo tlib  ( ?!)   h3p://www.cityinabo3le.org/nodebox/   Flock_example.py  
  • 5. NODEBOX OPENGL from nodebox.graphics import * def draw(canvas): canvas.clear() nofill() Set  context  values   stroke(0, 0.25) strokewidth(1) X,  Y,  width,  height   Local  override  of  context   rect( 50, 50, 50, 50) values   rect(110, 50, 50, 50, stroke=Color(0), strokestyle=DASHED) rect(170, 50, 50, 50) canvas.run(draw) 0,0  in  lower  leB  by  default  (top   leB  in  NB  1!)  
  • 6. NODEBOX 1 IS A SMART IDE Implicit  canvas,  draw,  etc.  
  • 7. DOWNLOAD NODEBOX Mac  too,  I’ll   TentaQve  evidence   demo   of  linux  too   http://nodebox.net/download/  
  • 8. GENERATIVE ART JusQn  D  on  flickr.    
  • 9.
  • 10. HIGH QUALITY GRAPHIC OUTPUT TODO.TO.IT  
  • 11.
  • 12. LIBRARIES IN NODEBOX 1 (MAC OSX) Note:  these  libraries  must  be  put  in  ~/Library/Application   Support/Nodebox  to  be  imported.  All  the  libs  live  here.  
  • 16. GRIDS
  • 19. If  you  do  data  visualization,  but  not  “art,”   WHY WOULD YOU NEED THIS TOOL?
  • 20. SKETCHES IN CODE Examples  from   Processing  sketches   by  JanWillem  Tulp  
  • 21.
  • 22. “Ghost  CounQes,”  by  @JanWillemTulp  
  • 23. UNUSUAL GRAPH TYPES Slopegraph  from  Juice  Analytics,  code  for  NB  1  
  • 24. TOOL CREATION My  sparklines  generator  in   NB  OGL   Example  sparks.py  in  NB  OGL  
  • 25. NODEBOX 1 “GUI” Example  bars_with_goals.py  for  NB1  
  • 26. CLOSEST SIMILAR TOOLS Drawbot  (Preceded  and  inspired  Nodebox,    MacOSX  only)   Shoebot  (MacOSX),  with  Spryte  for  Windows    (some  examples  run  unchanged  in  NB1!)   Pythonista  on  Ipad!       Processing  (cross  platform,  includes  .js  port)    (Processing.py  by  jpheinberg  is  jython-­‐based.)  
  • 27. PROCESSING LOOKS LIKE JAVA L Plus,  obviously,  I  want  Python  libs   h3p://openprocessing.org/sketch/8941  
  • 28. Very,  very  short  intro  to  the  concepts…   DRAWING BASICS
  • 29. NODEBOX 1 PRIMITIVES Most  of  them  in  NB  OGL   Note:  no  triangle()  as  in  Nodebox  OGL;  “oval”  instead  of  “ellipse”  as  in  OGL  
  • 30. SHAPE PRIMITIVES IN NODEBOX OGL NOTE:  ellipse()  not  oval()  as  in  NB1  
  • 31. THE DRAW() LOOP Nodebox  1  can  be  used  for  simple  static  image   without  animation  –  no  canvas  declaration    or   draw  loop  needed.    (Use  speed(<fps>)  to  turn  on   the  animation.)     Nodebox  OGL    always  runs  an  animation  loop  in   a  draw  function  (you  can  exit  out  with  a  return   after  canvas.frame==1  in  “draw”  if  you  want)       mycanvas = Canvas(width=600, height=480) mycanvas.fps = 20 mycanvas.run(draw=draw,setup=setup)
  • 32. DRAWING CONTEXT CHANGES State  context  changers:     colormode(), fill(), stroke(), strokewidth(),   nofill(), nostroke() font(), fontsize() transform(), translate(), rotate(), scale(), skew()     Temporary  state  changes:        push() fill(0) translate(200,200) pop()  
  • 33. NOTICE THE CONTEXT AGAIN… from nodebox.graphics import * def draw(canvas): canvas.clear() nofill() Set  context  values   stroke(0, 0.25) strokewidth(1) X,  Y,  width,  height   Local  override  of  context   rect( 50, 50, 50, 50) values   rect(110, 50, 50, 50, stroke=Color(0), strokestyle=DASHED) rect(170, 50, 50, 50) canvas.run(draw)
  • 34. LEARNING THE “REST” §  Examples  with  both  NB  1  and  NB  OGL   distribs:  commented  and  by  topic   §  Tutorials  on  the  NB  1  site     §  The  extensive  intro  page  for  NB  OGL  (that   builds  off  NB1’s  api  background)  
  • 35. Getting  Real(ly  dirty  and  sketchy)   MY TOY EXAMPLES
  • 36.
  • 37. FICTION INVESTIGATION… Shane  Bergsma’s  db  of  noun  gender  (based  on   Google  news  crawling):  [see  refs]        “word  male  female  neutral  plural”,  e.g.:        publication  93    20    3152  110     1.  Load  Shane’s  db  into  redis   2.  Convert  books  to  txt  (blank  line  bw  paragraphs)   3.   Extract  nouns  with  pattern.py     4.  Code  each  with  tuple  (m,  f,  n)  &  %’s     5.  Write  out  as  csv  for  use  in  Nodebox  scripts  
  • 38. COORDINATES IN COLOR AND 3-SPACE Neutral   Male   Female  
  • 39. FOOTNOTE: HSV IN THE BLUE-RED RANGE / WITH DARKNESS Code  borrowed  from  an  example  on  StackOverflow  –  tuned  to  get  only  hue  from   blue  to  red  from  complete  HSV  range  
  • 40. GET CARTESIAN X, Y COORD FROM A TUPLE def to_cart(triple): (m, f, n) = triple x = ( f + n / 2.0) y = math.sqrt(3) * n / 2.0 return x, y Code  in  my  common.py  file  
  • 41. INTERPOLATION You  often  need  to  map  from  a  data  range  to  another  range   (of  pixels,  or  color  points…).  Mapping  my  X  and  Y  to  colors:     from scipy.interpolate import interp1d hue_scale = interp1d([0,1],[.67,1])   For  pythonic  hsv  color  and  then  nodebox  rgb:     hsv = (hue_scale(x)[0], 1, 1-y[0]) rgb = Color(colorsys.hsv_to_rgb(*hsv)) I  am  flipping   the  V!  
  • 43. EVENTS : LAYERS, MOUSE, KEYS Layers  in  NB  OGL  are  one  good  way  you  might   handle  “mouseover”  functionality   Layers  have  their  own  draw()  functionality,  and  the   canvas  knows  that  layer  is  in  focus  (under  the  mouse,  via   canvas.focus)     Mouse  events  are  also  handled  nicely  by   canvas.mouse  –  mouse.x,  mouse.y,  etc.  are   available                                                                                          See  my  example  triangle_layers.py  
  • 45. MOUSE & KEYBOARD EVENTS mouse  =  canvas.mouse   mouse.x                                                                    #  Horizontal  position.   mouse.y                                                                    #  Vertical  position.   NB  OGL:  h3p://www.cityinabo3le.org/nodebox/   mouse.relative_x                                #  Relative  (0.0-­‐1.0)  to  Canvas.width.   mouse.relative_y                                #  Relative  (0.0-­‐1.0)  to  Canvas.height.   mouse.dx                                                              #  Drag  distance  from  previous  x.   mouse.dy                                                              #  Drag  distance  from  previous  y.   mouse.pressed                                        #  True  if  the  mouse  button  is  pressed.   mouse.dragged                                      #  True  if  the  mouse  is  dragged.   mouse.cursor                                                #  DEFAULT,  CROSS,  HAND,  HIDDEN,  TEXT,  WAIT   mouse.button                                              #  LEFT,  RIGHT,  MIDDLE   mouse.modifiers                                    #  List  of:  CTRL,  SHIFT,  OPTION   keys  =  canvas.keys   keys[]                                                                                #  All  keys  pressed  (SHIFT  +  "a"  =>  [SHIFT,  "a"]).   keys.char                                                                  #  Last  key  pressed  (SHIFT  +  "a"  =>  "A").   keys.code                                                              #  Last  key  pressed  (SHIFT  +  "a"  =>  "a").   keys.modifiers                                            #  List  of  modifier  keys  (CTRL,  SHIFT,  OPTION).   keys.pressed                                                  #  True  if  a  key  is  pressed  on  the  keyboard.  
  • 46. LAYERS GOT EVENTS TOO layer.enabled                                                            #  True  =>  will  receive  events.   layer.pressed                                                              #  True  =>  mouse  pressed  on  layer.   NB  OGL:  h3p://www.cityinabo3le.org/nodebox/   layer.dragged                                                            #  True  =>  mouse  dragged  on  layer.   layer.focus                                                                        #  True  =>  mouse  hovering  over  layer.   layer.on_mouse_enter(mouse)   layer.on_mouse_leave(mouse)   layer.on_mouse_motion(mouse)   layer.on_mouse_press(mouse)   layer.on_mouse_release(mouse)   layer.on_mouse_drag(mouse)   layer.on_mouse_scroll(mouse)   layer.on_key_press(keys)   layer.on_key_release(keys)  
  • 47. MOUSEOVER    Triangle_layers.py  
  • 48. A FAILED EXPERIMENT CAN STILL BE FUN… ADDING ANIMATION. Angels  &  Demons  (Brown)   Twilight  (Meyer)   “jade”   Pride  &  Prejudice  (Austen)   The  Secret  Agent  (Conrad)      triangle_bar_uniq.py  
  • 49. GETTING BLUNTER… 2 ON ONE: Doesn’t  show  much…   sigh.  
  • 50. JUST GET EVEN BLUNTER… Centroid  of  each…  a  li3le   more  revealing  maybe?   Definitely  not  for  publicaQon!  
  • 51. THERE CAN BE VALUE IN “MISTAKES” WHEN VISUALIZING DATA AT PIXEL LEVEL Thanks  to  MarQn  Wa3enberg   and  Fernanda  Viegas  for  this   observaQon…  
  • 52. A MORE INTERESTING MISTAKE… If  you  don’t  filter  out  duplicate  menQons  of  the  same   noun….  
  • 53. Twilight   Angels  &  Demons   Triangle_hist_notuniq.py  
  • 54. Twilight   Angels  &  Demons   (uniqued)   (uniqued)   Triangle_hist_uniq.py  
  • 55. RATIO OF NOUNS TO UNIQUE NOUNS (AS EXPECTED NOW) Unique   Nouns/   Nouns/ Nouns   Words       Nouns   Unique   Words   Angels  &   19546   2842   6.9   151610   7.8   Demons   Twilight   18252   1943   9.4   121205   6.6  
  • 56. Twilight  (most  repeated)   Angels  &  Demons  (most  repeated)   Line_freqs.py  
  • 57. HOOKING UP OTHER PYTHON LIBS 1.  Load  a  book  into  redis  by  line  #   2.  Plot  dialog  vs.  exposition  in  a  simple  colored   bar   3.  Use  the  redis  db  to  see  what’s  what  in  the   book  on  rollover!     Simple,  and  very  fast!  
  • 58.
  • 59. DIALOG TO EXPOSITION… Twilight     Angels  &  Demons   Secret  Agent   Pride  &  Prejudice   Moby  Dick   (Meyer)   (Brown)   Para  groups:  7   Quote_bar_nodb.py  
  • 60. Phew!  That  was  a  lot  of  stuff.   WRAP UP…
  • 61. WHY OR WHY NOT NODEBOX? Advantages     §  Data  as  “art”  –  not  supported  by  Matplotlib  (or   future  ggplot2  ports  to  python)   §  Data  “sketching”  –    speedy  unstructured  pics   §  Animation  is  basic   §  Events  come  along  too   §  You  get  to  write  in  Python  (unlike  w/  Processing)   §  So  you  can  use  other  Python  libs    
  • 62. BUT… §  No  3d  (unlike  matplotlib)   §  PDF  or  SVG  Export  are  required  for  good  print/reuse  (available  in   NB  1,  not  in  NB  OGL  yet)   §  No  web  embedding  /  js  version  (unlike  processing.js)   §  Can’t  use  with  IPython  notebook  (yet)   §  Challenge  of  other  python  libs  with  NB  1  -­‐  sad  PYTHONPATH   problem  in  Nodebox  1  (see  appendix  for  tips)   §  Authors  in  Leuven  more  focused  on  NB  3/Pattern.py  than  on  NB1  /   OGL  versions.          Can  we  invigorate  Nobebox  OpenGL?     §  A  general  lack  of  code  examples  to  draw  from…  hopefully  mine  will   help!  
  • 63. THAT’S IT - A BIG THANKS! @deepfoo  for  the  reminder  of  Nodebox1,   Tom  De  Smedt  and  Frederik  De  Bleser  for   email  help,  @minrk  for  help,  @jsundram  for   code  cleanup  advice  (not  all  of  which  I  took),   @pwang  and  #PyData  for  having  me  
  • 64. Find  me  @arnicas,  www.ghostweather.com   blog   GET THE CODE FILES HERE! PDF OF THESE SLIDES HERE. Apologies  for  the  import  *  and  the  globals…    I  was  following  some   suggesQons  in  the  demos  I  looked  at  which  may  not  have  been  ideal.  
  • 65. REFERENCES §  JanWillem  Tulp  Ghost  Counties  images:  http://www.flickr.com/photos/janwillemtulp/sets/72157626612248205/   §  Code  for  ternary  plots  in  python  and  excel:   http://sourceforge.net/projects/wxternary/  and  Will  Vaughn’s  at   http://wvaughan.org/ternaryplots.html   §  Nodebox  flickr  gallery   §  Running  Nodebox  1  from  command  line:   http://nodebox.net/code/index.php/Console   §  Pattern.py  by  Tom  de  Smedt  (a  Nodebox  original  author)   §  Nodebox  authors  Tom  De  Smedt  and  Frederik  De  Bleser  in  Belgium   §  Shane  Bergsma  and  Dekang  Lin,  “Bootstrapping  Path-­‐Based  Pronoun   Resolution,”  In  Proceedings  of  the  Conference  on  Computational   Lingustics  /  Association  for  Computational  Linguistics  (COLING/ ACL-­‐06),  Sydney,  Australia,  July  17-­‐21,  2006.  (page  w/  db)  
  • 66. APPENDIX: NODEBOX 1’S IMPORT PATH Custom  path,  includes  its  own  python  (64  bit)…  so….   –  You  can  install  your  packages  into  NodeBox’s  path,  ie.,  ~/ Library/Application  Support/NodeBox/  —  meaning  that  you   can  use  them  from  NodeBox,  but  not  from  other  scripts…   –  You  can  import  sys  in  your  NodeBox  code  and  manually  modify   the  sys.path  value  to  add  your  existing  packages…   –  You  can  install  packages  into  your  system  site-­‐packages   directory,  and  sym-­‐link  them  from  NodeBox’s  directory…   –  You  can  make  NodeBox  use  your  system  packages  instead  of   it’s  own  by  sym-­‐linking  ~/Library/Application  Support/ NodeBox  to  your  site-­‐packages  directory  of  choice  (ex.,  / Library/Python/2.5/site-­‐packages)   –  Some  flavor  of  above  plus  VIRTUALENV   Tips  from  h3p://www.eriksmar3.com/blog/archives/747   Thread  here  too:  h3p://nodebox.net/code/index.php/shared_2008-­‐09-­‐04-­‐01-­‐42-­‐29  
  • 67. APPENDIX: NODEBOX1 AT COMMAND LINE… §  Instructions  and  samples  here:   http://nodebox.net/code/index.php/Console   §  Best  to  use  a  virtualenv  again  
  • 68. THE NODEBOX “FAMILY” Nodebox  1   Platform  &  “style”   Mac  OSX  only  (kind  of   Status   No  longer  in  dev,  spotty   URLs   Mac  OSX  Lion  file:   Lion)  –  write  python  code   archiving  online   https://secure.nodebox.net/  (the  original)   downloads/ in  a  simple  IDE   NodeBox-­‐1.9.7rc1.zip   Home:   http://nodebox.net/code/ index.php/Home   Github  copy  of  svn  source:   https://github.com/nodebox/ nodebox-­‐pyobjc     Nodebox  2     Mac  OSX  –  python  visual   GONE!    Apparently  was   Home:   (the  disappeared)   programming  “blocks”   slow  and  confusing?   http://Beta.nodebox.net   Nodebox  3     Mac  and  Windows  –  no   Not  so  interesting  to  me:  I   Home:   IDE,  no  python  exposed,   want  to  write  python     http://nodebox.net/node/   (the  current     beta)   all  visual  programming?   code.   Nodebox   Mac  and  Windows  –  write   Not  up  to  date  with   Home:   plain  python  code   Nodebox  1  yet  (e.g.,  lack   http://www.cityinabottle.org/ OpenGL  (the   nodebox/     incomplete)   of  libraries,  lack  of   Github  code:   functionality;  not  so  well   https://github.com/nodebox/ documented);  can’t  run  in   nodebox-­‐opengl   IPython  notebook  due  to     probable  multithreading     issue(s)