Python mathplotlib

2024-09-30 14:27:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python的新手,但我想绘制一些图表,但我遇到了一个错误-->值错误:x和y不能大于2D,但具有形状(1,)和(1738,7) 我如何才能删除过多的列。 亲切问候:)

    import yfinance as yf
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

BTC_EUR = yf.Ticker("BTC-EUR")
hist = [BTC_EUR.history(period="max")]
rec = BTC_EUR.recommendations
info = BTC_EUR.info
price = BTC_EUR.info['regularMarketPrice']
supply = BTC_EUR.info['circulatingSupply']
market_cap = price*supply
moskau_zeit = 1/price*100000000
fiftytwoweeks = BTC_EUR.info['fiftyTwoWeekLow']
price_since_fiftytwoweeks = (price/fiftytwoweeks-1)*100
day_low = BTC_EUR.info['dayLow']
day_high = BTC_EUR.info['dayHigh']

print(hist)
print(price)
#print(BTC_EUR.major_holders)

#for key,value in info.items():                  
 #print(key, ":", value) 


if price < day_low:
  print(f"Buy! The price is at {price:,.2f} EUR/BTC")
  
if price > day_high:
 print(f"Dont buy now, too expensive! The price is at {price:,.2f} EUR/BTC")

if price > day_low and price < day_high:
 print(f"Wait, market isnt moving rn! The price is at {price:,.2f} EUR/BTC")
 
print(f"There are {supply:,.2f} BTC in circulation. This is {supply/21000000*100:,.2f}% of the aggregate supply.")
print(f"The market cap is {market_cap:,.2f} high")
print(f"The moskau time is {moskau_zeit:,.2f} SAT/EUR")
print(f"The price of BTC has risen by {price_since_fiftytwoweeks:,.2f}% since the 52 weeks-low of {fiftytwoweeks:,.2f} euros")
plt.plot(hist)
plt.figure(figsize= (12,12))
plt.xlabel('Zeit')
plt.ylabel('Kurspreis')
plt.show()

Tags: theimportinfoisasplteurmarket