0

Am in a stage in my application where am trying to comeup with a statistics interface(graphs,charts) based on the data in the sqlalchemy database am using. However I came across matplotlib and i am trying to get along along with it but still failing to implement it. Am using Mako templates. Am requesting on how to go about this.Thanks heres sam view's code.

@view_config(route_name="d", renderer="./templates/d.mako")
def d(request):
    try:
       rows = DBSession.query(Song.duration, Song.price).all()
       duration,price = zip(*rows)
       plt.plot(duration,price)
       ##show()
    except DBAPIError:
    return Response(conn_err_msg, content_type='text/plain', status_int=500)
return { 'project': 'beatstore'}
uralbash
  • 3,219
  • 5
  • 25
  • 45
Maurice Elagu
  • 764
  • 1
  • 10
  • 20

1 Answers1

0

See here for how to save a map after generating it, then just put it inside static and render as an image with your template.

Community
  • 1
  • 1
crooksey
  • 8,521
  • 6
  • 30
  • 52