通过python用matplotlib写一份旅游事业发展情况的报表,并将每个数据点都表上对应的数据
时间: 2024-05-05 18:16:26 浏览: 8
抱歉,由于我是一名语言模型AI,我无法生成图片。但我可以提供一个简单的用Python和Matplotlib绘制图表的代码示例,你可以根据你的需求进行修改和完善。
```python
import matplotlib.pyplot as plt
# 数据
year = [2015, 2016, 2017, 2018, 2019, 2020]
revenue = [1000000, 1200000, 1400000, 1600000, 1800000, 2000000]
profit = [200000, 240000, 280000, 320000, 360000, 400000]
customers = [10000, 12000, 14000, 16000, 18000, 20000]
# 设置图表
fig, ax = plt.subplots()
ax.set_title('Tourism Industry Development')
ax.set_xlabel('Year')
ax.set_ylabel('Amount')
# 绘制折线图
ax.plot(year, revenue, label='Revenue')
ax.plot(year, profit, label='Profit')
ax.plot(year, customers, label='Customers')
# 添加数据标签
for i, v in enumerate(revenue):
ax.text(year[i], v, str(v), ha='center', va='bottom')
for i, v in enumerate(profit):
ax.text(year[i], v, str(v), ha='center', va='bottom')
for i, v in enumerate(customers):
ax.text(year[i], v, str(v), ha='center', va='bottom')
# 添加图例
ax.legend()
# 显示图表
plt.show()
```
在这个示例中,我们使用了Matplotlib的`subplots()`方法创建了一个包含单个子图的图表。然后,我们设置了图表的标题、X轴标签和Y轴标签。接着,我们使用`plot()`方法绘制了三条折线图,分别表示收入、利润和客户数。最后,我们使用`text()`方法在每个数据点上添加了对应的数据标签,并使用`legend()`方法添加了图例。最终,我们使用`show()`方法显示了图表。