Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matplotlib String on y axe
#1
Hello everyone,

I'm having some issue with this sample code using histogram & matplotlib, i can't display a bar for the first value Satisfaisant:

import json
import datetime
import requests
import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

r = requests.get('https://dgal.opendatasoft.com/api/records/1.0/search/?dataset=export_alimconfiance&q=rouen&facet=libelle_commune&facet=date_inspection&facet=app_libelle_activite_etablissement&facet=synthese_eval_sanit&facet=filtre&facet=ods_type_activite')
data=r.json()

sites = data["records"]
with open('city.csv', 'w', newline='') as file:
	writer = csv.writer(file)
	writer.writerow(["Name", "Synthesis"])
	for elt in sites:
		writer.writerow([elt["fields"]["app_libelle_etablissement"], elt["fields"]["synthese_eval_sanit"]])
		print(elt["fields"]["app_libelle_etablissement"])
		print("	|" + elt["fields"]["app_libelle_activite_etablissement"])
		print("	|" + elt["fields"]["ods_type_activite"])
		print("	|" + elt["fields"]["ods_adresse"])
		print("	|" + elt["fields"]["synthese_eval_sanit"])
		print()

table = pd.read_csv("city.csv")

file = open("city.csv")
reader = csv.reader(file)
lines= len(list(reader))
plt.bar(x=np.arange(1,lines),height=table['Synthesis'])
table.head()
plt.title("Restaurants Synthesis")
plt.xticks(np.arange(1,lines), table['Name'], rotation='33', fontsize=5)
plt.yticks(rotation='50', fontsize=8)
plt.xlabel("Restaurants")
plt.ylabel("Synthesis")
plt.show()
Can you help me? Thank you,

Best regards
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,251 Mar-11-2021, 10:52 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020