Python Seaborn Heat-map not plotting all pandas columns
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

No all cols are plotting. XML for example does not plot. Apologies for the size of the dict, it's an intermittent problem.

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
test_data= {'ASP.NET': [0, 0, 0, 0, 4, 5, 0, 0, 4, 0, 3, 4, 0, 2, 0, 0, 0], 
            'Angular 2+': [0, 0, 0, 0, 0, 3, 2, 0, 2, 3, 4, 4, 2, 0, 0, 0, 2], 
            'Angular.js': [0, 0, 0, 0, 0, 3, 3, 0, 3, 4, 4, 2, 4, 3, 0, 0, 2], 
            'Autosys': [0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 
            'BASH': [0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0], 
            'Batch processing': [0, 0, 0, 0, 3, 3, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0], 
            'Bootstrap': [0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 3, 2, 4, 0, 0, 0, 3], 
            'C': [0, 0, 0, 1, 4, 1, 0, 0, 4, 4, 3, 3, 3, 3, 0, 0, 3], 
            'C#': [0, 0, 0, 0, 4, 5, 0, 0, 4, 0, 3, 5, 0, 2, 0, 0, 0], 
            'C++': [0, 0, 0, 1, 0, 1, 0, 0, 2, 4, 0, 3, 3, 3, 0, 0, 0], 
            'CSS with HTML': [0, 0, 0, 3, 3, 5, 0, 0, 4, 5, 3, 2, 5, 2, 0, 0, 3], 
            'D3.js': [0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 2, 0, 0, 0, 0, 0], 
            'Databases': [0, 0, 4, 4, 0, 5, 0, 0, 4, 3, 3, 3, 3, 3, 0, 0, 4], 
            'ES6': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 0, 0, 0, 0, 3], 
            'Flask': [0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 3, 0, 0, 0, 2], 
            'HTML5': [0, 0, 0, 0, 3, 3, 0, 0, 2, 5, 3, 2, 4, 3, 0, 0, 4], 
            'Hibernate': [0, 0, 0, 3, 0, 0, 4, 0, 0, 2, 3, 0, 0, 0, 0, 0, 3], 
        'JSON': [0, 0, 0, 2, 3, 2, 3, 0, 1, 3, 4, 4, 0, 3, 0, 0, 5], 
        'Java': [0, 0, 0, 4, 2, 2, 4, 0, 4, 3, 4, 2, 4, 4, 0, 3, 5], 
        'JavaBeans': [0, 0, 0, 4, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5], 
        'JavaScript': [0, 0, 0, 3, 3, 3, 4, 0, 4, 4, 3, 4, 4, 2, 0, 0, 4], 
        'Logging Frameworks': [0, 0, 0, 3, 0, 0, 4, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4], 
        'PL/SQL (Oracle)': [0, 0, 4, 2, 4, 5, 3, 0, 3, 2, 3, 3, 0, 0, 0, 4, 4], 
        'Perl': [0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0], 
        'Python': [0, 0, 3, 0, 0, 2, 0, 0, 3, 3, 0, 2, 3, 0, 0, 0, 2], 
        'SQL': [0, 0, 4, 4, 4, 5, 0, 0, 0, 4, 3, 3, 3, 3, 0, 4, 4], 
        'Servlet': [0, 0, 0, 3, 0, 0, 4, 0, 0, 0, 3, 0, 0, 0, 0, 0, 4], 
        'Shell': [0, 0, 0, 3, 3, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], 
        'Spring': [0, 0, 0, 3, 3, 2, 4, 0, 0, 3, 3, 0, 3, 3, 0, 0, 4], 
        'Spring - Boot': [0, 0, 0, 0, 3, 1, 3, 0, 0, 3, 4, 0, 3, 2, 0, 0, 4], 
        'Spring - Rest': [0, 0, 0, 0, 3, 0, 3, 0, 0, 0, 4, 0, 3, 3, 0, 0, 4], 
        'Swagger': [0, 0, 0, 0, 2, 1, 2, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0], 
        'TypeScript': [0, 0, 0, 0, 0, 2, 0, 0, 1, 3, 3, 2, 0, 0, 0, 0, 0], 
        'UNIX Shell Scripting': [0, 0, 0, 3, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 
        'Underscore.js': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0], 
        'VBA (Microsoft Access/Office)': [0, 0, 0, 0, 0, 2, 0, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0], 
        'VBScript': [0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0], 
        'Visual C# .NET': [0, 0, 0, 0, 3, 5, 0, 0, 4, 0, 3, 4, 0, 2, 0, 0, 0], 
        'Web Components': [0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 1, 0, 0, 0, 0, 3], 
        'XML': [0, 0, 3, 4, 3, 2, 0, 0, 1, 0, 3, 3, 0, 2, 0, 0, 4], 
        'XSD': [0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0], 
        'XSL': [0, 0, 3, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], 
        'jQuery': [0, 0, 0, 0, 2, 2, 0, 0, 4, 2, 3, 3, 0, 1, 0, 0, 3]}

labels = ["na", "poor", "average", "good", "excellent"]
df = pd.DataFrame(test_data)
plt.xticks(fontsize="9",rotation=45)
plt.yticks(fontsize="9")
plt.yticks(np.arange(4),['Tom', 'Dick', 'Sue','Ben'], rotation=0)
plt.yticks(rotation=45)
ax = sns.heatmap(df, cmap="YlGnBu", annot=False, yticklabels=(['Tom', 'Dick', 'Sue', "Ben"]))
ax.tick_params(axis='y', rotation=0)
cbar = ax.collections[0].colorbar
cbar.set_ticks([1, 2, 3, 4, 5])
cbar.set_ticklabels(labels)
plt.show()
Tags
python3

Crowdsource coding tasks.

1 Solution


Hi @broadreach!

The complete script is here: https://paste.ofcode.org/7NKknTK6sqawmRgrS8gHYe

Documented as well :)

Thank you, Vladimir.