0

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) enter image description here

im expecting to see a histogram of "borough"

rickhg12hs
  • 10,638
  • 6
  • 24
  • 42
  • post the code and not the pictures of code. Users need to be able to replicate the problem quickly, which text allows for (and pictures do not). https://stackoverflow.com/help/how-to-ask – D.L Jan 11 '23 at 16:04
  • Welcome! Can you please read about [the problems with images of text](//meta.stackoverflow.com/a/285557/11107541)? Likely useful: [/help/formatting](/help/formatting) – starball Jan 11 '23 at 20:39

1 Answers1

0

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?

Fourchette
  • 251
  • 5