当前位置:   article > 正文

PyEcharts 基本图表之雷达图_

第1关 Radar:雷达图(一)

  1. from PreTest import *
  2. from pyecharts import options as opts
  3. from pyecharts.render import make_snapshot
  4. from snapshot_phantomjs import snapshot
  5. from pyecharts.charts import Radar
  6. data1 = [[4300, 10000, 28000, 35000, 50000, 19000]]
  7. data2 = [[5000, 14000, 28000, 31000, 42000, 21000]]
  8. def radar_chart() -> Radar:
  9. # ********* Begin *********#
  10. radar = (
  11. Radar()
  12. .add_schema(
  13. schema=[
  14. opts.RadarIndicatorItem(name="销售", max_=6500),
  15. opts.RadarIndicatorItem(name="管理", max_=16000),
  16. opts.RadarIndicatorItem(name="信息技术", max_=30000),
  17. opts.RadarIndicatorItem(name="客服", max_=38000),
  18. opts.RadarIndicatorItem(name="研发", max_=52000),
  19. opts.RadarIndicatorItem(name="市场", max_=25000),
  20. ],
  21. )
  22. .add(series_name="预算分配",data=data1)
  23. .add(series_name="实际开销",data=data2)
  24. .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
  25. .set_global_opts(
  26. title_opts=opts.TitleOpts(title="Radar-单例模式"),
  27. legend_opts=opts.LegendOpts(selected_mode="single"),
  28. )
  29. )
  30. # ********** End **********#
  31. return radar
  32. make_snapshot(snapshot, radar_chart().render("Result/render.html"), 'StudentAnswer/student_answer.png') # 输出图片
  33. make_snapshot(snapshot, radar_base(data1, data2).render(), "StandardAnswer/task1/standard_answer_1.png")

第2关 Radar:雷达图(二) 

  1. from PreTest import *
  2. from pyecharts import options as opts
  3. from pyecharts.render import make_snapshot
  4. from snapshot_phantomjs import snapshot
  5. from pyecharts.charts import Radar
  6. data_bj = [
  7. [55, 9, 56, 0.46, 18, 6, 1],
  8. [25, 11, 21, 0.65, 34, 9, 2],
  9. [56, 7, 63, 0.3, 14, 5, 3],
  10. [33, 7, 29, 0.33, 16, 6, 4],
  11. [42, 24, 44, 0.76, 40, 16, 5],
  12. [82, 58, 90, 1.77, 68, 33, 6],
  13. [74, 49, 77, 1.46, 48, 27, 7],
  14. [78, 55, 80, 1.29, 59, 29, 8],
  15. [267, 216, 280, 4.8, 108, 64, 9],
  16. [185, 127, 216, 2.52, 61, 27, 10],
  17. [39, 19, 38, 0.57, 31, 15, 11],
  18. [41, 11, 40, 0.43, 21, 7, 12],
  19. ]
  20. data_sh = [
  21. [91, 45, 125, 0.82, 34, 23, 1],
  22. [65, 27, 78, 0.86, 45, 29, 2],
  23. [83, 60, 84, 1.09, 73, 27, 3],
  24. [109, 81, 121, 1.28, 68, 51, 4],
  25. [106, 77, 114, 1.07, 55, 51, 5],
  26. [109, 81, 121, 1.28, 68, 51, 6],
  27. [106, 77, 114, 1.07, 55, 51, 7],
  28. [89, 65, 78, 0.86, 51, 26, 8],
  29. [53, 33, 47, 0.64, 50, 17, 9],
  30. [80, 55, 80, 1.01, 75, 24, 10],
  31. [117, 81, 124, 1.03, 45, 24, 11],
  32. [99, 71, 142, 1.1, 62, 42, 12],
  33. ]
  34. radar_schema = [
  35. {"name": "AQI", "max": 300, "min": 5},
  36. {"name": "PM2.5", "max": 250, "min": 20},
  37. {"name": "PM10", "max": 300, "min": 5},
  38. {"name": "CO", "max": 5},
  39. {"name": "NO2", "max": 200},
  40. {"name": "SO2", "max": 100},
  41. ]
  42. def radar_chart() -> Radar:
  43. # ********* Begin *********#
  44. radar = (
  45. Radar()
  46. .add_schema(schema=radar_schema, shape="circle")
  47. .add("北京",data_bj,color='#f9713c')
  48. .add("上海",data_sh,color='#b3e4a1')
  49. .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
  50. .set_global_opts(title_opts=opts.TitleOpts(title="Radar-空气质量"))
  51. )
  52. # ********** End **********#
  53. return radar
  54. make_snapshot(snapshot, radar_chart().render("Result/render.html"), "StudentAnswer/student_answer.png") # 输出图片
  55. make_snapshot(snapshot, radar_air_quality(data_bj, data_sh, radar_schema).render(), "StandardAnswer/task2/standard_answer_2.png")

 第3关 Radar:雷达图(三)

  1. from PreTest import *
  2. from pyecharts import options as opts
  3. from pyecharts.render import make_snapshot
  4. from snapshot_phantomjs import snapshot
  5. from pyecharts.charts import Radar
  6. # ********* Begin *********#
  7. data = [{"value": [4, -4, 2, 3, 0, 1], "name": "预算分配"}]
  8. radar_schema = [
  9. {"name": "销售", "max": 4, "min": -4},
  10. {"name": "管理", "max": 4, "min": -4},
  11. {"name": "技术", "max": 4, "min": -4},
  12. {"name": "客服", "max": 4, "min": -4},
  13. {"name": "研发", "max": 4, "min": -4},
  14. {"name": "市场", "max": 4, "min": -4},
  15. ]
  16. # ********** End **********#
  17. def radar_chart() -> Radar:
  18. # ********* Begin *********#
  19. radar = (
  20. Radar()
  21. .set_colors(['#4587E7'])
  22. .add_schema(
  23. schema=radar_schema,
  24. shape='circle',
  25. center=['50%','50%'],
  26. radius='80%',
  27. angleaxis_opts=opts.AngleAxisOpts(
  28. min_=0,
  29. max_=360,
  30. is_clockwise=False,
  31. interval=5,
  32. axistick_opts=opts.AxisTickOpts(is_show=False),
  33. axislabel_opts=opts.LabelOpts(is_show=False),
  34. axisline_opts=opts.AxisLineOpts(is_show=False),
  35. splitline_opts=opts.SplitLineOpts(is_show=False),
  36. ),
  37. radiusaxis_opts=opts.RadiusAxisOpts(
  38. min_=-4,
  39. max_=4,
  40. interval=2,
  41. splitarea_opts=opts.SplitAreaOpts(
  42. is_show=True,
  43. areastyle_opts=opts.AreaStyleOpts(opacity=1)
  44. ),
  45. ),
  46. polar_opts=opts.PolarOpts(),
  47. splitarea_opt=opts.SplitAreaOpts(is_show=False),
  48. splitline_opt=opts.SplitLineOpts(is_show=False),
  49. )
  50. .add(
  51. series_name="预算",
  52. data=data,
  53. areastyle_opts=opts.AreaStyleOpts(opacity=0.1),
  54. linestyle_opts=opts.LineStyleOpts(width=1),
  55. )
  56. )
  57. # ********** End **********#
  58. return radar
  59. make_snapshot(snapshot, radar_chart().render("Result/render.html"), 'StudentAnswer/student_answer.png') # 输出图片
  60. make_snapshot(snapshot, radar_angle_radius_axis(data, radar_schema).render(), "StandardAnswer/task3/standard_answer_3.png")

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/196719
推荐阅读
相关标签
  

闽ICP备14008679号