Ask Your Question

Revision history [back]

list_plot only showing one axis

I'm trying to plot price series from Yahoo Finance using list_plot, however it only plots the values on x-axis, when it would be on the y-axis. I tried using list_plot(prices) and making tuples of (x,price). Please see the following code:

import json
import requests

simb = 'IRBR3'
js = '********query1.finance.yahoo.com/v8/finance/chart/' + simb + '.SA?symbol=' + simb + '.SA&period1=0&period2=9999999999&interval=1d'  #please modify the asterisks to correct the https link, not enough karma to publish links :-(

response = requests.get(js)
yf = json.loads(response.text)
prices=yf['chart']['result'][0]['indicators']['adjclose'][0]['adjclose']
#list_plot(prices)     #doesn't work
#pts = [(float(x),y) for x in range(len(prices)-1) for y in prices]
pts=list(zip(range(len(prices)-1),prices))
list_plot(pts)    #doesn't work either

Is there any configuration lacking? Or maybe a "data mistyping"?