简体   繁体   中英

Pymongo and Matplotlib

How do I generate graphs with matplotlib that show the distribution values of some variables of a JSON file? for example in this picture, i need to make a hist graph of "borough"(im using pymongo at a notebook) 在此处输入图像描述

im expecting to see a histogram of "borough"

Can you try something like this?

import matplotlib.pyplot as plt
x = [i for i in range(len(query_borough)]
h = [doc['result'] for doc in query_borough]
t = [doc['_id'] for doc in query_borough]
plt.bar(x, height=h)
plt.xticks(x,t);

Based on How to plot a histogram using Matplotlib in Python with a list of data?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM