摘要: Python如何设置对数log坐标系的range fig, ax = plt.subplots() sns.lineplot(data=df, x="k", y="pk") ax.set_xscale("log") ax.set_yscale("log") ax.set_xlim(3, 1e2) a 阅读全文
posted @ 2022-05-19 17:58 bH1pJ 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 问题抽象:Python如何绘制曲线的阴影图? 建议的方案: flights = sns.load_dataset("flights") flights.head() sns.lineplot(data=flights, x="year", y="passengers") plt.show() 效果如 阅读全文
posted @ 2022-05-19 17:08 bH1pJ 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 使用networkx构建随机网络 有两种方法: 也可以直接调用库函数来生成这两种网络 n, m, p = 20,40,0.2 #节点数、边数、连边概率; g1 = nx.gnm_random_graph(n, m) #根据连边数,确定随机网络 g2 = nx.gnp_random_graph(n, 阅读全文
posted @ 2022-05-19 14:19 bH1pJ 阅读(89) 评论(0) 推荐(0) 编辑
摘要: from scipy import optimize import numpy as np #定义需要拟合的函数 def fit_line(x, a, b): return a*x + b k, pk = get_dgreeDistr(BA) kmin = np.min(k) kmax = np.m 阅读全文
posted @ 2022-05-19 11:59 bH1pJ 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 自己手把手写一个计算度分布的函数:基本思路,两层for循环,定义 def get_dgreeDistr(G): all_k = [G.degree(i) for i in G.nodes()] #获取每个节点的度值; k = list(set(all_k)) N = len(G.nodes()) P 阅读全文
posted @ 2022-05-19 11:20 bH1pJ 阅读(22) 评论(0) 推荐(0) 编辑
摘要: python使用使用对数坐标系 newX = [] newY = [] for i in range(len(x)): if y[i] != 0 : newX.append(x[i]) newY.append(y[i]) fig, ax = plt.subplots() ax.plot(newX,n 阅读全文
posted @ 2022-05-19 10:59 bH1pJ 阅读(118) 评论(0) 推荐(0) 编辑