0

I have 10 network realisations of the number of occurences for certain substructures in a web decomposition algorithm. I am considering the 10 most important webs and so I have ten entries in each list where each list is a realisation of the network. Basically I have a list of lists:

full_l2 = [[1, 1, 1, 1, 1, 1, 1, 1, 3, 1], 
           [1, 1, 1, 1, 1, 2, 2, 2, 1, 1], 
           [1, 1, 1, 1, 1, 2, 1, 1, 1, 1], 
           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 
           [1, 1, 1, 1, 1, 3, 1, 1, 2, 2], 
           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 
           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 
           [1, 3, 1, 1, 1, 1, 1, 1, 1, 1], 
           [1, 1, 1, 1, 1, 1, 2, 1, 1, 1], 
           [1, 1, 1, 1, 1, 1, 1, 1, 2, 1]]

The numbers in the list tells the number of substructures and each list has the webs in decreasing order of importance. So I used:

occ = []
    for i in range(10):
        a = list(zip(*full_l2))[i]
        occ.append(a)

to get the 1st, 2nd and so on upto 10th important webs. Now the occurences will look like:

occ =  [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 
        (1, 1, 1, 1, 1, 1, 1, 3, 1, 1), 
        (1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 
        (1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 
        (1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 
        (1, 2, 2, 1, 3, 1, 1, 1, 1, 1), 
        (1, 2, 1, 1, 1, 1, 1, 1, 2, 1), 
        (1, 2, 1, 1, 1, 1, 1, 1, 1, 1), 
        (3, 1, 1, 1, 2, 1, 1, 1, 1, 2), 
        (1, 1, 1, 1, 2, 1, 1, 1, 1, 1)]

So, I plot the histogram for the number of occurences. I am showing just 10 realisations so that the lists are easier to understand but I want to do it for 1000. I just used:

plt.hist(occ)
plt.yscale(log)

and I get a plot like this:

For 1000 realisations of networks

But I need to have it as a colormap. I tried using:

cm = plt.cm.get_cmap('jet')

and like this answer here: Plot histogram with colors taken from colormap

but it has a problem:

ValueError: color kwarg must have one color per dataset

I need it to look like:

With a colormap]

Does anyone know if I am missing something?

jtweeder
  • 751
  • 3
  • 19
Monali
  • 43
  • 7
  • Please also add the code you use to print the histogram. Try to make a minimal example that can be copy pasted and executed. – JohanC Nov 05 '19 at 15:28
  • `cm = plt.cm.get_cmap('jet')` only assigns a colormap to a variable `cm`. You'll need to tell matplotlib somewhere to use it for the histograms. – JohanC Nov 05 '19 at 15:30
  • Yes I tried doing it like this answer here: https://stackoverflow.com/questions/23061657/plot-histogram-with-colors-taken-from-colormap but it doesn't give me anything. – Monali Nov 05 '19 at 15:32
  • 1
    So, you must be doing something different as in that other question. Without showing your code, you are the only one who can answer your question. – JohanC Nov 05 '19 at 16:12

0 Answers0