title: How change the color of boxes in confusion matrix using sklearn?
body: <p>Here is my code snippet to produce confusion matrix:
  I am wondering how can I change the color of boxes in confusion matrix for those boxes which are not located in diagonal same as heatmap using sklearn.</p>
  <pre><code>nb_classes = 15    
  confusion_matrix = torch.zeros(nb_classes, nb_classes)
  
  with torch.no_grad():
      for i, (inputs, target, classes, im_path) in enumerate(dataLoaders['test']):
          
          inputs = inputs.to(device)
          target = target.to(device)
  
          outputs = model(inputs)
          _, preds = torch.max(outputs, 1)
  
          for t, p in zip(target.view(-1), preds.view(-1)):
                  confusion_matrix[t.long(), p.long()] += 1
                  
  num_classes = 15
  class_names = ['A2CH', 'A3CH', 'A4CH_LV', 'A4CH_RV', 'A5CH', 'Apical_MV_LA_IAS',
                   'OTHER', 'PLAX_TV', 'PLAX_full', 'PLAX_valves', 'PSAX_AV', 'PSAX_LV',
                   'Subcostal_IVC', 'Subcostal_heart', 'Suprasternal']                
      
  plt.figure()
  plt.imshow(confusion_matrix, interpolation='nearest', cmap=plt.cm.Blues)
  
  tick_marks = numpy.arange(num_classes)
  classNames = class_names
     
  thresh = confusion_matrix.max() / 2.
  for i in range(confusion_matrix.shape[0]):
      for j in range(confusion_matrix.shape[1]):
          plt.text(j, i, format(confusion_matrix[i, j]),
                  ha=&quot;center&quot;, va=&quot;center&quot;,
                  color=&quot;white&quot; if  confusion_matrix[i, j] == 0 or confusion_matrix[i, j] &gt; thresh else &quot;black&quot;) 
  plt.tight_layout()
  plt.colorbar()
  return plt
  plt.show()   
  </code></pre>
  <p><a href="https://i.stack.imgur.com/PNBTX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PNBTX.jpg" alt="enter image description here" /></a></p>