首页 > 编程语言 >元进Python(4)---networkx制作我最喜爱55部美剧天体排名

元进Python(4)---networkx制作我最喜爱55部美剧天体排名

时间:2022-11-12 10:02:08浏览次数:53  
标签:60 部美剧 Python --- 00FF00 70 90 80 MyUSTVNode

利用networkx和matplotlib给我最喜爱的55部美剧来个天体排名

【最终呈现效果】

元进Python(4)---networkx制作我最喜爱55部美剧天体排名_networkx

【代码实现及注释】

import networkx as nx
import matplotlib.pyplot as plt

USTVNode=['Everybody Loves Raymond','Friends','Sex and the City','Desperate Housewives','Two and a Half Men',
'30 Rock','Ugly Betty','How I Met Your Mother','Modern Family','The Big Bang Theory','Veep','Silicon Valley',
'The Marvelous Mrs. Maisel','Two Broken Girls','Breaking Bad','Billions','Seinfeld','Prison Break',
'House of Cards','Monk','The Mentalist','Good Luck Charlie','Hanna Montana','Gossiple Girl','Heroes',
'CSI','Greys Anatony','24 hours','Criminal Minds','Bones','Westworld','Lost','Supernatural','Growing Pains',
'Better Call Saul','White Collar','Law & Order','The Good Wife','Wizards of Waverly Place','Mom','True Blood',
'The Last Man on Earth','Community','The 100','Without a Trace','The Shield','Southland','The Rookie',
'Masters of Sex','Orange Is the New Black','The Chair','Fresh Off the Boat','Mistresses','Significant Mother','Smallville']
#输入我最喜欢的美剧名称,形成列表USTVNode
USTVRank=['80','99','70','90','92','62','60','80','85','91','80',
'75','70','80','95','94','90','96','80','90','85','70',
'73','79','70','76','65','60','70','74','75','60','88',
'89','92','87','90','86','69','75','61','77','70','66',
'62','76','71','60','61','68','75','63','65','76','80']
#给对每部美剧的喜爱程度打分,分数越高越好
i=0

ranking={}
while i<len(USTVNode):
ranking.update({USTVNode[i]:USTVRank[i]})
i+=1
MyRanking = sorted(ranking.items(), key=lambda x: x[1], reverse=True)
#给美剧从高到低排序


MyUSTVNode=[]
MyUSTVRank=[]
for x in MyRanking:
MyUSTVNode.append(x[0])
MyUSTVRank.append(x[1])
mapping={}
for x in MyUSTVNode:
mapping.update({MyUSTVNode.index(x): x})
US=[int(x)*30 for x in MyUSTVRank]
#节点标签映射

USTVRank=[270, 265, 260, 255, 250, 245, 240, 235, 230, 225, 220,
215, 210, 205, 200, 195, 190, 185, 180, 175, 170, 165,
160, 155, 150, 145, 140, 135, 130, 125, 120, 115, 110,
105, 100, 95, 90, 85, 80, 75, 70, 65, 60,55,
50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0]
US=[int(x)*15 for x in USTVRank]
#绘制球体的体积大小数列

NodeColor=['#FFC0CB', '#DC143C', '#FFF0F5', '#DB7093', '#FF69B4', '#FF1493',
'#C71585', '#DA70D6', '#D8BFD8', '#DDA0DD', '#EE82EE', '#FF00FF',
'#FF00FF', '#8B008B', '#800080', '#BA55D3', '#9400D3', '#9932CC',
'#00FF00', '#8A2BE2', '#9370DB', '#7B68EE', '#6A5ACD', '#483D8B',
'#E6E6FA', '#F8F8FF', '#00FF00', '#00FF00', '#00FF00', '#00FF00',
'#90EE90', '#98FB98', '#8FBC8F', '#32CD32', '#00FF00', '#D8BFD8',
'#B0C4DE', '#DDA0DD', '#7FFF00', '#7CFC00', '#ADFF2F', '#FFF0F5',
'#F5F5DC', '#FAFAD2', '#FFFFF0', '#FFFFE0', '#FFFF00', '#E6E6FA',
'#BDB76B', '#FFFACD', '#000080', '#4169E1', '#6495ED', '#B0C4DE', '#FAEBD7']
#球体颜色列表

G=nx.path_graph(55)
G.add_nodes_from(MyUSTVNode)
nx.draw(nx.relabel_nodes(G,mapping),pos=nx.spiral_layout(G),with_labels=True,
font_size='14',font_color='black',font_weight='bold',edge_color='g',
node_shape='o',node_color=NodeColor, node_size=US)

plt.show()

标签:60,部美剧,Python,---,00FF00,70,90,80,MyUSTVNode
From: https://blog.51cto.com/dcboy/5846531

相关文章

  • MAUI新生-目录
    MAUI是微软.NET技术栈的跨端UI框架,2022年11月,和.NET7一起正式发布,未来能否和flutter一战?MAUI使用XAML标记语言进行开发,相对HTML而言,更加复杂和繁琐,但功能更加全面严谨。MA......
  • 第四十四章 在CSP应用程序中本地化文本 - 显示本地化字符串的其他选项
    目录第四十四章在CSP应用程序中本地化文本-显示本地化字符串的其他选项显示本地化字符串的其他选项%response.GetTextMethodFormatTextMethod$$$FormatTextMacrosMat......
  • 2022-11-11 这10天,纳斯达克V形反转的一点记录
    1.从11月2号开始,首先已经跌破上升趋势线2.联席会议开始,多头突然发力,2段上涨3.结果空头发力,多空争夺激烈。空头回落到多头的1/2甚至2/3以下,一定要出了!开盘,收盘,事件,会......
  • 篇(4)-Asp.Net Core入门实战-使用ADO.NET
    入门实战-在Asp.NETCORE中使用ADO.NET在讲EF的配置之前,我想说下基于ADO.NET的数据库操作方式:原来做项目时,都是要有个DBHelper文件,来进行数据库的增删改查操作,那么在Asp.n......
  • ASP.NET Core教程-Configuration(配置)-配置IIS配置(IIS integration)
    更新记录转载请注明出处:2022年11月12日发布。2022年11月8日从笔记迁移到博客。配置IIS配置(IISintegration)默认情况下,ASP.NETCore应用程序是自托管的如果我们......
  • 升级 Net 7 随手笔记 (注意事项以及解决方案) - 持续更新
    条件编译#ifNET6_0改为#ifNET7_0或者#ifNET6_0_OR_GREATER#ifNET6_0_OR_GREATERusingBootstrapBlazor.Components;#endif项目目标支持6和7改为<TargetF......
  • ElfReader-Elf文件类型
    ElfReader-Elf文件类型参考文献链接https://github.com/jianhong-li/ElfReaderhttps://www.cnblogs.com/lwyeric/p/13582022.htmlELF文件解析程序说明:用Java解析E......
  • Typescript类型体操 - Unique
    题目中文实现类型的Lodash.uniq,Unique接受数组T,返回没有重复值的数组TEnglishImplementthetypeversionofLodash.uniq,UniquetakesanArrayT,returns......
  • Typescript类型体操 - LastIndexOf
    题目中文实现类型的Array.lastIndexOf,LastIndexOf<T,U>接受泛型参数ArrayT和anyU并返回数组T中最后一个U的索引示例:typeRes1=LastIndexOf<[1,2,3......
  • GL-Suggesting a book 20221104
    TopicSuggestingabookWhichbookisbeingdescribed?Canyouthinkofanymoregenres?IsShakespeareyourfavoriteauthororisAgathaChristiemoreyour......