matplot 绘图总结
生活随笔
收集整理的這篇文章主要介紹了
matplot 绘图总结
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
figure = plt.figure()
tick_plot = figure.add_subplot(2, 1, 1)
tick_plot.plot(X_data, Y_data, label='true', color='green', linestyle='-')
tick_plot.axvline(x=X_data[-long_predict], alpha=0.2, color='gray') # 添加垂直線
tick_plot.plot(X_prediction, y_prediction, label='pre', color='red', linestyle='--')
plt.legend()
tick_plot = figure.add_subplot(2, 1, 2)
tick_plot.plot(X_prediction,error)
plt.show()
?
Country_stats.plot(kind='scatter', x="GDP per capita", y='Life satisfaction')? ?Plot中添加X、y軸標簽
繪制熱圖:
import matplotlib.image as mpimg california_img=mpimg.imread(PROJECT_ROOT_DIR + '/images/end_to_end_project/california.png') ax = housing.plot(kind="scatter", x="longitude", y="latitude", figsize=(10,7),s=housing['population']/100, label="Population",c="median_house_value", cmap=plt.get_cmap("jet"),colorbar=False, alpha=0.4,) plt.imshow(california_img, extent=[-124.55, -113.80, 32.45, 42.05], alpha=0.5) plt.ylabel("Latitude", fontsize=14) plt.xlabel("Longitude", fontsize=14)prices = housing["median_house_value"] tick_values = np.linspace(prices.min(), prices.max(), 11) cbar = plt.colorbar() cbar.ax.set_yticklabels(["$%dk"%(round(v/1000)) for v in tick_values], fontsize=14) cbar.set_label('Median House Value', fontsize=16)plt.legend(fontsize=16) save_fig("california_housing_prices_plot") plt.show()? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
california.png為:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
總結
以上是生活随笔為你收集整理的matplot 绘图总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 膨胀卷积(Dilated convolu
- 下一篇: R语言与数据分析:时间序列简单介绍