我想從一組用戶輸入值繪製直方圖。Python:繪製直方圖向下
好吧,我在我的代碼更新到這一點:
number1 = ""
number2 = ""
number3 = ""
number4 = ""
numbers = input("Enter a string of positive integers separated by spaces: ")
print(" ")
newNum = numbers.split()
line = 0
col = 0
lines = int(max(newNum))
length = len(newNum)
while line<lines:
col = 0
while col<length:
if line<int(newNum[col]):
print('* ', end = '')
else:
print(' ')
col = col+1
line = line+1
print("")
但是當我運行的代碼,我得到這樣的:
Enter a string of positive integers separated by spaces: 1 3 20 5
* * * *
* * *
* * *
* *
* *
什麼我現在缺讓我的直方圖打印這樣的?另外,它爲什麼不將值打印到20?
Enter a string of positive integers separated by spaces: 1 3 20 5
* * * *
* * *
* * *
* *
* *
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
你嘗試過什麼?你卡在哪裏?請參閱[如何問](https://stackoverflow.com/questions/ask/advice?)。 –
上面的代碼是我得到的。我只是不確定如何讓它翻轉。 –
我不知道你的應用程序,但它會是一個選項使用scipy或matplotlib條形圖? – Kev1n91