title: Plotting the degree distribution of a graph using nx.degree_histogram
body: <p>I've tried to use the following code to plot the degree distribution of the <code>networkx.DiGraph</code> <code>G</code>:</p>
  
  <pre><code>def plot_degree_In(G):
      in_degrees = G.in_degree()
      in_degrees=dict(in_degrees)
      in_values = sorted(set(in_degrees.values()))
      in_hist = [list(in_degrees.values()).count(x) for x in in_values]
  
      plt.figure() 
      plt.grid(False)
      plt.loglog(in_values, in_hist, 'r.') 
      #plt.loglog(out_values, out_hist, 'b.') 
      #plt.legend(['In-degree', 'Out-degree'])
      plt.xlabel('k')
      plt.ylabel('p(k)')
      plt.title('Degree Distribution')
      plt.xlim([0, 2*100**1])
  </code></pre>
  
  <p>But then I realized that this is not the proper way to do it and so I changed it to:</p>
  
  <pre><code>def plot_degree_dist(G):
      degree_hist = nx.degree_histogram(G) 
      degree_hist = np.array(degree_hist, dtype=float)
      degree_prob = degree_hist/G.number_of_nodes()
      plt.loglog(np.arange(degree_prob.shape[0]),degree_prob,'b.')
      plt.xlabel('k')
      plt.ylabel('p(k)')
      plt.title('Degree Distribution')
      plt.show()
  </code></pre>
  
  <p>But this gives me an empty plot with with no data in it.</p>