基于Python pyecharts实现多种图例代码解析

2020/08/26 02:53 · python教程 ·  原创文章 · 51阅读 · 0评论

词云图

from pyecharts.charts import WordCloud
def word1():
  words= [
    ("Sam S Club", 10000),
    ("Macys", 6181),
    ("Amy Schumer", 4386),
    ("Jurassic World", 4055),
    ("Charter Communications", 2467),
    ("Chick Fil A", 2244),
    ("Planet Fitness", 1868),
    ("Pitch Perfect", 1484),
    ("Express", 1112),
    ("Home", 865),
    ("Johnny Depp", 847),
    ("Lena Dunham", 582),
    ("Lewis Hamilton", 555),
    ("KXAN", 550),
    ("Mary Ellen Mark", 462),
    ("Farrah Abraham", 366),
    ("Rita Ora", 360),
    ("Serena Williams", 282),
    ("NCAA baseball tournament", 273),
    ("Point Break", 265),
  ]
  worldcloud = (
    WordCloud()
    .add("", words, word_size_range=[20, 100])
    .set_global_opts(title_opts=opt.TitleOpts(title="WorldCloud-shape-diamond"))
  )
  # worldcloud = (
  #   WordCloud()
  #   .add("", words, word_size_range=[20, 100], shape=SymbolType.DIAMOND)
  #   .set_global_opts(title_opts=opt.TitleOpts(title="WorldCloud-shape-diamond"))
  # )
  worldcloud.render("wordl.html")
  os.system("wordl.html")

效果如下:

您可能感兴趣的文章

本文地址:http://www.pythongcs.cn/744.html
文章标签:
版权声明:本文为原创文章,版权归 sanhe 所有,欢迎分享本文,转载请保留出处!

文件下载

老薛主机终身7折优惠码boke112

上一篇:
下一篇:

 发表评论


表情