Ask Your Question

list_plot only showing one axis

asked 2020-06-23 19:18:37 +0200

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 22:06:17 +0200

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 16:12:32 +0200 )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 20:38:20 +0200 )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 19:18:37 +0200

Seen: 261 times

Last updated: Jun 23 '20