Python 金融入门
Adina Howe
Professor
点击此链接查看更多 Matplotlib 图库。

import matplotlib.pyplot as plt
plt.plot()
plt.show()
import matplotlib.pyplot as plt
plt.plot(months, prices)
plt.show()

import matplotlib.pyplot as plt
plt.plot(months, prices, color = 'red')
plt.show()

import matplotlib.pyplot as plt
plt.plot(months, prices, color = 'red', linestyle = '--')
plt.show()

| 颜色 | |
|---|---|
| 'green' | 绿色 |
| 'red' | 红色 |
| 'cyan' | 青色 |
| 'blue' | 蓝色 |
| 线型 | |
|---|---|
| '-' | 实线 |
| '--' | 虚线 |
| '-.' | 点划线 |
| ':' | 点线 |
更多颜色与线型文档见此处。
import matplotlib.pyplot as plt
plt.plot(months, prices, color = 'red', linestyle = '--')
# Add labels
plt.xlabel('Months')
plt.ylabel('Consumer Price Indexes, $')
plt.title('Average Monthly Consumer Price Indexes')
# Show plot
plt.show()

import matplotlib.pyplot as plt
plt.plot(months, prices, color = 'red', linestyle = '--')
# adding an additional line
plt.plot(months, prices_new, color = 'green', linestyle = '--')
plt.xlabel('Months')
plt.ylabel('Consumer Price Indexes, $')
plt.title('Average Monthly Consumer Price Indexes')
plt.show()

import matplotlib.pyplot as plt
plt.scatter(x = months, y = prices, color = 'red')
plt.show()

Python 金融入门