teslariu

grafico radar

Feb 6th, 2021
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. from openpyxl import Workbook
  5. from openpyxl.chart import (
  6.     RadarChart,
  7.     Reference,
  8. )
  9.  
  10. wb = Workbook()
  11. ws = wb.active
  12.  
  13. rows = [
  14.     ['Mes', "Bulbos", "Semillas", "Flores", "Arboles & arbustos"],
  15.     ['Jan', 0, 2500, 500, 0,],
  16.     ['Feb', 0, 5500, 750, 1500],
  17.     ['Mar', 0, 9000, 1500, 2500],
  18.     ['Apr', 0, 6500, 2000, 4000],
  19.     ['May', 0, 3500, 5500, 3500],
  20.     ['Jun', 0, 0, 7500, 1500],
  21.     ['Jul', 0, 0, 8500, 800],
  22.     ['Aug', 1500, 0, 7000, 550],
  23.     ['Sep', 5000, 0, 3500, 2500],
  24.     ['Oct', 8500, 0, 2500, 6000],
  25.     ['Nov', 3500, 0, 500, 5500],
  26.     ['Dec', 500, 0, 100, 3000 ],
  27. ]
  28.  
  29. for row in rows:
  30.     ws.append(row)
  31.  
  32. chart = RadarChart()
  33. chart.type = "filled"
  34. labels = Reference(ws, min_col=1, min_row=2, max_row=13)
  35. data = Reference(ws, min_col=2, max_col=5, min_row=1, max_row=13)
  36. chart.add_data(data, titles_from_data=True)
  37. chart.set_categories(labels)
  38. chart.style = 26
  39. chart.title = "Ventas de Jardineria"
  40. chart.y_axis.delete = True
  41.  
  42. ws.add_chart(chart, "A17")
  43.  
  44. wb.save("radar.xlsx")
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment