我正在尝试使用从Excel提取的一维列表在图中绘制简单的条形图。该文件显示正常(myList = ['45,21,45,54,87,34,52,78,9,79']),我假设我将其拆分为字符串列表。我现在想将它们更改为int,以便Plotly可以将图表识别为唯一的一个大条形图(我猜字符串都在一起吗?)
import plotly.graph_objects as go
file = open("myFile.csv", "r") *
myData= file.read()
myList = myData.split("\n")
print(myList)
newList = []
for element in myList:
newList.append(int(element))
print(newList)
y = (myList)
fig = go.Figure([go.Bar(y=y)])
fig.update_layout(title_text='This is my bar chart displaying my figures')
fig.show()
y = (myList)
B)是不是因为这里:fig = go.Figure([go.Bar(y=y)])
您将旧列表与字符串一起使用,而不是使用newlist
?