Skip to content

Commit

Permalink
Make demo generate prettier tree pic
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed May 4, 2018
1 parent cfe7d89 commit c8a5c44
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
queue = cl.CommandQueue(ctx)

dims = 2
nparticles = 10**4
nparticles = 500

# -----------------------------------------------------------------------------
# generate some random particle positions
Expand All @@ -26,7 +26,7 @@
# -----------------------------------------------------------------------------
from boxtree import TreeBuilder
tb = TreeBuilder(ctx)
tree, _ = tb(queue, particles, max_particles_in_box=30)
tree, _ = tb(queue, particles, max_particles_in_box=5)

from boxtree.traversal import FMMTraversalBuilder
tg = FMMTraversalBuilder(ctx)
Expand All @@ -40,12 +40,25 @@

import matplotlib.pyplot as pt

pt.plot(particles[0].get(), particles[1].get(), "x")
pt.plot(particles[0].get(), particles[1].get(), "+")

from boxtree.visualization import TreePlotter
plotter = TreePlotter(tree.get(queue=queue))
plotter.draw_tree(fill=False, edgecolor="black")
plotter.draw_box_numbers()
#plotter.draw_box_numbers()
plotter.set_bounding_box()
pt.gca().set_aspect("equal")
pt.savefig("tree.png")
pt.tight_layout()
pt.tick_params(
axis='x', # changes apply to the x-axis
which='both', # both major and minor ticks are affected
bottom='off', # ticks along the bottom edge are off
top='off', # ticks along the top edge are off
labelbottom='off')
pt.tick_params(
axis='y',
which='both',
left='off',
top='off',
labelleft='off')
pt.savefig("tree.pdf")

0 comments on commit c8a5c44

Please sign in to comment.