- Matplotlib for Python Developers
- Aldrin Yim Claire Chung Allen Yu
- 116字
- 2021-08-27 18:48:20
Multiline plots
For example, to create a multiline plot, we can draw a line plot for each data series before concluding the figure. Let's try plotting the temperatures of three different cities with the following code:
import matplotlib.pyplot as plt
# Prepare the data series
d = [11,12,13,14,15,16,17]
t0 = [15.3,15.4,12.6,12.7,13.2,12.3,11.4]
t1 = [26.1,26.2,24.3,25.1,26.7,27.8,26.9]
t2 = [22.3,20.6,19.8,21.6,21.3,19.4,21.4]
# Plot the lines for each data series
plt.plot(d,t0)
plt.plot(d,t1)
plt.plot(d,t2)
plt.show()
Here is the plot generated by the preceding code:

This example is adapted from the maximum temperatures of three cities in a week in December 2017. From the graph, can you recognize which two lines are more likely to be representative of cities from the same continent?
推薦閱讀
- Learning Python Web Penetration Testing
- DB2 V9權(quán)威指南
- Mastering matplotlib
- PHP 7+MySQL 8動態(tài)網(wǎng)站開發(fā)從入門到精通(視頻教學版)
- JavaCAPS基礎、應用與案例
- Java系統(tǒng)化項目開發(fā)教程
- Terraform:多云、混合云環(huán)境下實現(xiàn)基礎設施即代碼(第2版)
- Kivy Cookbook
- Visual Basic程序設計習題與上機實踐
- Clojure for Java Developers
- Java程序設計教程
- 微前端設計與實現(xiàn)
- Applied Deep Learning with Python
- Getting Started with JUCE
- 關系數(shù)據(jù)庫與SQL Server 2012(第3版)