Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
96 views
in Technique[技术] by (71.8m points)

python - whats wrong with the graph

Please see what,s wrong with my code So here is my code:

import pandas as pd
import matplotlib.pyplot as plt
di = pd.read_csv("iris.csv")
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
sl=list(datainput['sepal_length'])
sw=list(datainput['sepal_width'])
c=['sepal_length','sepal_width']
sl=0
sw=0
plt.ylabel("Number")
plt.show()
question from:https://stackoverflow.com/questions/65923897/whats-wrong-with-the-graph

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I tested your code with a different csv file where all the columns had the same length and it plotted the correct number of bars. I suspect that's the source of the problem since you only have 3 complete columns in your data. Also, lines 15 through 43 of your code (all the for loops and append statements) can be replaced with a single line:

tc = [sum(rgn1), sum(rgn2), sum(rgn3), sum(rgn4), sum(rgn5), sum(rgn6), sum(rgn7)]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...