Skip to content

Instantly share code, notes, and snippets.

@stuartlynn
Created August 3, 2017 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartlynn/d0116687d94c6a2afd46b288068963ce to your computer and use it in GitHub Desktop.
Save stuartlynn/d0116687d94c6a2afd46b288068963ce to your computer and use it in GitHub Desktop.
bar plot end point
@app.route('/bar.img')
def bar():
query = request.args.get('q')
username = request.args.get('username')
api_key = request.args.get('apikey')
xlabel = request.args.get('xlabel')
ylabel = request.args.get('ylabel')
title = request.args.get('title')
data = carto_query(query,username,api_key)
fig = Figure()
ax = fig.add_subplot(111)
data.set_index('cat').plot(kind='barh',ax=ax)
ax.set_title(title)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
return mpl2img(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment