2

Trying to make a log-log scale log binned plot. Wondering if someone can give me some advice on how to approach this problem. Thanks.

import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import powerlaw

G = nx.Graph()
G = nx.read_edgelist('data.txt', create_using=nx.DiGraph, nodetype = int)

M = nx.to_scipy_sparse_matrix(G)
xmin = min([d[1] for d in G.degree()])
indegrees = M.sum(0).A[0]
degree = np.bincount(indegrees)
fit = powerlaw.Fit(np.array(degree)+1, fit_method='KS')
    
    
fig = plt.figure(figsize=(16, 6)) 

plt.subplot(1, 3, 1)
plt.plot(range(len(degree)),degree,'b.')   
plt.loglog()
plt.xlim((min(degree), max(degree)))
plt.xlabel('Degree')
plt.ylabel('P(k)')
plt.show()

What I current have

enter image description here

What I am trying to get

enter image description here

bombombs
  • 593
  • 1
  • 13
  • Could you expand what you are trying to do? Because what you are trying to get is basically what you have... – AveragePythonEnjoyer Oct 04 '22 at 11:28
  • @AveragePythonEnjoyer I am trying to get is the log-log plot of degree distribution using logarithmic binning visible in red. What I currently have visible from my plot is a log-log plot with linear binning. – bombombs Oct 04 '22 at 12:48
  • Does this answer your question? [Scaled logarithmic binning in python](https://stackoverflow.com/questions/37170511/scaled-logarithmic-binning-in-python) – CRuizH Oct 25 '22 at 13:44

0 Answers0