我在绘制模型预测周围的区域时遇到了麻烦,我认为使用fill_between绘制会很简单。
有关可重现的示例:
df1
Ground_Truth Predictions Predictions_hi Predictions_lo
410 15.0 14.810122 18.356809 11.263436
85 26.6 27.131472 28.320380 25.942565
280 45.4 45.404620 47.274549 43.534691
422 20.8 19.081849 20.711096 17.452601
199 34.9 29.703281 32.416996 26.989566
364 21.9 49.010702 52.162232 45.859172
5 28.7 27.330305 29.026654 25.633956
415 7.2 8.412145 10.244244 6.580046
209 20.0 17.257462 19.459939 15.054985
284 32.2 28.166823 30.390787 25.942859
json格式的数据:
{"Ground_Truth":{"410":15.0,"85":26.6,"280":45.4,"422":20.8,"199":34.9,"364":21.9,"5":28.7,"415":7.2,"209":20.0,"284":32.2},"Predictions":{"410":14.8101220869,"85":27.1314724323,"280":45.4046198732,"422":19.0818488429,"199":29.7032811382,"364":49.0107021787,"5":27.3303047283,"415":8.4121453666,"209":17.2574622383,"284":28.1668228107},"Predictions_hi":{"410":18.3568086485,"85":28.3203798966,"280":47.2745488681,"422":20.7110962223,"199":32.4169963433,"364":52.1622320467,"5":29.0266538906,"415":10.2442444504,"209":19.4599393417,"284":30.3907868523},"Predictions_lo":{"410":11.2634355254,"85":25.9425649679,"280":43.5346908782,"422":17.4526014635,"199":26.989565933,"364":45.8591723107,"5":25.6339555659,"415":6.5800462828,"209":15.054985135,"284":25.9428587691}}
我的代码如下:
results_df1.plot(x= 'Ground_Truth', y = 'Predictions', kind = 'scatter', color = 'r')
plt.plot(results_df1['Ground_Truth'],results_df1['Ground_Truth'], color = 'b')
plt.fill_between(results_df1['Ground_Truth'], results_df1['Predictions_lo'], results_df1['Predictions_hi'], alpha = 0.1)
plt.show()
此代码返回以下图:
您看到了我没想到的跳汰机。