Mit gleichen Daten Linien-Diagram läuft und Balken-Diagramm nicht
Verfasst: Freitag 15. Dezember 2017, 14:51
Hi,
ich möchte Balkendiagramm erzeugen. Statt mehrere Balken bekomme ich ein grosses Rechteck. Und Liniendiagramm mit gleichen Daten funktioniert ganz gut.
Hat jemand Idee wo ich Fehler habe?
ich möchte Balkendiagramm erzeugen. Statt mehrere Balken bekomme ich ein grosses Rechteck. Und Liniendiagramm mit gleichen Daten funktioniert ganz gut.
Hat jemand Idee wo ich Fehler habe?
Code: Alles auswählen
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
#from config.txt import polo_key, polo_secret
import requests, json
import numpy as np
import matplotlib.pyplot as plt
def public_method(command): #holt die daten aus Poloniex. Typ dict
#Variablen für Funktion:
#returnLoanOrders¤cy=LTC -> gibt daten von Verleiverlauf für LTC
url = 'https://poloniex.com/public?command={0}'.format(command)
api = requests.get(url)
data = json.loads(api.text)#json-Format in python-dict konvertieren
return data
Date_Lean_LTC = public_method('returnLoanOrders¤cy=LTC')# Verlei-Daten aus Poloniex rausholen
first_key = list(Date_Lean_LTC)[0]
#print(first_key)
first_list = Date_Lean_LTC[first_key]
#print(first_list)
#print(first_list[0]['rate'])
a_rate = []
a_amount = []
a_rangeMin = []
a_rangeMax = []
for second_dict in first_list:
#print(second_dict)
print(second_dict['rate'], second_dict['amount'], second_dict['rangeMin'], second_dict['rangeMax'])
a_rate = np.append(a_rate, second_dict['rate'])
a_amount = np.append(a_amount, second_dict['amount'])
a_rangeMin = np.append(a_rangeMin, second_dict['rangeMin'])
a_rangeMax = np.append(a_rangeMax, second_dict['rangeMax'])
x = a_rate.astype(float)
y = a_amount.astype(float)
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
#ax1.plot(x,y)
ax1.bar(x,y)
plt.show()