Skip to content

Instantly share code, notes, and snippets.

@ruivieira
Created March 12, 2018 19:25
Show Gist options
  • Select an option

  • Save ruivieira/8a0805c954d0427eb5254de9ffa0b085 to your computer and use it in GitHub Desktop.

Select an option

Save ruivieira/8a0805c954d0427eb5254de9ffa0b085 to your computer and use it in GitHub Desktop.
import numpy as np
from matplotlib import cm
import matplotlib.pyplot as plt
sample=np.array(['a1','a2','a3','a4','a5','a6'])
y_pos = np.arange(len(sample))
probability=np.array([0.1, 0.05, 0.05, 0.2, 0.4, 0.2])
colours = cm.Blues(probability / max(probability))
p = plt.scatter(y_pos, probability, alpha=0.5, c=probability, cmap = 'Blues')
plt.clf()
plt.colorbar(p)
plt.bar(range(len(probability)), [1]*len(sample), color = colours)
plt.xticks(y_pos, sample)
plt.ylabel('probability')
plt.title('Category probabilities')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment