Echarts可视化教程

  1. 网站首页
  2. 百度ECharts
  3. ECharts实例
  4. ECharts入门
  5. 地图大全
  6. ECharts官网

Python绘制图表(柱状图示例二)

import matplotlib.pyplot as plt
import numpy as np
 
# 产品销售额数据
product_a = [1000, 1200, 1500, 1800, 2000]
product_b = [800, 900, 1200, 1500, 1700]
product_c = [600, 800, 1000, 1200, 1400]
 
# 年份数据
years = ['2019', '2020', '2021', '2022', '2023']
 
# 绘制柱状图
x = np.arange(len(years))
width = 0.2
 
plt.bar(x - width, product_a, width, label='Product A')
plt.bar(x, product_b, width, label='Product B')
plt.bar(x + width, product_c, width, label='Product C')
 
plt.title('Annual Sales by Product')
plt.xlabel('Year')
plt.ylabel('Sales ($)')
plt.xticks(x, years)
plt.legend()
plt.show()
点击展开全文

相关文章

  1. Python结合ggplot库实现图表绘制
  2. Python绘制图表(柱状图示例)
  3. Python绘制图表(折线图示例二)
  4. Python绘制图表(折线图示例一)
  5. 如何利用Python绘制多维图表(饼图)