0
I have a code with 3 variables: a1, a2 and dc1.The variable dc1 is the absolute difference value of a2 and a1. I am generating a graph in matplotlib with the values of the a1 variable and would like the colors of colorbar to be defined by the values of the dc1 variable. But I can’t do it.
Below follows my code.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
a1 = np.array([1.5,2.5,2.0,5.5,7.0])
a2 = np.array([5.0,7.5,1.0,8,9])
dc1 = np.abs(a2-a1)
idx=np.arange(len(a1))
plt.scatter(idx,a1,s=dc1*100, c=dc1, cmap="BuPu",
edgecolors="black", linewidth=0.90)
plt.title(" MLP Keras")
plt.xlabel('Amostras\n')
plt.ylabel('Discrepâncias(m)')
plt.colorbar(dc1)
plt.grid(True)
plt.show()
Grateful for the attention