Advertisement
milanmetal

[Python] (Multiple) Histogram Plot

Jul 27th, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1.     # https://matplotlib.org/examples/statistics/histogram_demo_multihist.html
  2.     fig, histograms = plt.subplots(nrows=1, ncols=2)
  3.     hist0, hist1 = histograms.flatten()
  4.  
  5.     colors = ['red', 'blue']
  6.     hist0.hist(
  7.         flatten_kernels[np.nonzero(flatten_kernels)],
  8.         bin_num,
  9.         histtype='bar',
  10.         color=colors[0],
  11.         label='Weights')
  12.     hist0.set_title("Layer " + str(layer_cfg.layer_id))
  13.     hist0.set_xlabel('Bin values')
  14.     hist0.set_ylabel('Value occurence')
  15.  
  16.     hist1.hist(layer_cfg.bias, bin_num, histtype='bar', color=colors[1])
  17.     hist1.set_title("Biases, layer " + str(layer_cfg.layer_id))
  18.     hist1.set_xlabel('Bin values')
  19.     hist1.set_ylabel('Value occurence')
  20.  
  21.     fig.tight_layout()
  22.     plt.grid(True)
  23.     plt.show()
  24.  
  25.     # n, bins, patches = plt.hist(
  26.     #     flatten_kernels[np.nonzero(flatten_kernels)],
  27.     #     bin_num,
  28.     #     facecolor='green',
  29.     #     label='Weights',
  30.     #     alpha=0.75)
  31.  
  32.     # n, bins, patches = plt.hist(
  33.     #     layer_cfg.bias, bin_num, facecolor='blue', label='Biases', alpha=0.75)
  34.  
  35.     # plt.xlabel('Bins')
  36.     # plt.ylabel('Max value occurence')
  37.     # plt.title("Layer " + str(layer_cfg.layer_id))
  38.     # plt.grid(True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement