我定義了一個自定義函數(shù)并將值列表保存到海岸線變量中。我確定這個變量中有變量,因?yàn)槲覈L試了 print(shoreline) 并且我能夠獲得值列表。此 for 循環(huán)將遍歷“文件夾”并每次為海岸線提供不同的列表?,F(xiàn)在,如果我嘗試下面的代碼,輸出圖是空的。奇怪的是我能夠獲得正確的標(biāo)題,而標(biāo)題是從值中派生出來的。但是 value 參數(shù)不知何故沒有傳遞到 plot 中。這不是 plt.show() 的問題,因?yàn)槔L圖顯示在輸出窗口中,但它不包含任何數(shù)據(jù)。我期待的正確情節(jié)是這樣的(使用不同的數(shù)據(jù))有人可以幫我解決這個問題嗎?from production import get_volumefor args in folders: shoreline = get_volume(args) import seaborn as sns import matplotlib.pyplot as plt import statistics median = statistics.median(shoreline) sns.set_style("ticks") ax1=sns.distplot(shoreline, bins=70, color="#1B87C0", kde_kws={"color": "k", "lw": 0.7, "alpha":0.8, "label": "KDE"},) ax1.set(xlabel = 'Elevation (m)', ylabel='Kernel density') ax1.set_title('Shoreline elevation distribution\n'+ args.stem+'\nMedian = '+str(median)) plt.legend(frameon=False, loc='upper left') figname = str(figure_path/ 'Shoreline_{}.png'.format(args.stem)) plt.savefig(figname, dpi = 300, bbox_inches='tight')**編輯:Matplotlib 的自動縮放不知何故不起作用,我的數(shù)據(jù)范圍從 81-100 并且軸一直到 1e6,這就是為什么情節(jié)似乎是空的。**
添加回答
舉報
0/150
提交
取消