Ask Your Question

list_plot only showing one axis

asked 2020-06-23 12:18:37 -0600

GeheimAgent gravatar image

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 = '********' + 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)
#list_plot(prices)     #doesn't work
#pts = [(float(x),y) for x in range(len(prices)-1) for y in prices]
list_plot(pts)    #doesn't work either

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2020-06-23 15:06:17 -0600

rburing gravatar image

De lijst prices lijkt een aantal keer None te bevatten, waardoor er iets misgaat in list_plot (weet niet precies waarom). Als je deze eruit filtert, bijvoorbeeld door ze op nul te zetten,

prices = [p if p is not None else 0 for p in prices]

dan lukt het wel:



edit flag offensive delete link more


Thank you for your help. I didn't check the values returned in prices, albeit I have not expected such plot behavior.

GeheimAgent gravatar imageGeheimAgent ( 2020-06-24 09:12:32 -0600 )edit

@GeheimAgent Indeed it is a very odd bug; I just reported it as trac ticket #29960 (with an explanation of why it happens).

rburing gravatar imagerburing ( 2020-06-24 13:38:20 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-06-23 12:18:37 -0600

Seen: 41 times

Last updated: Jun 23 '20