a1 a2 are numbers between 0-1 use python to draw a1 a2 so that the color changes with the size of the value
Here's a code snippet that can draw (a1, a2) with changing color based on the size of the value:
import matplotlib.pyplot as plt
a1 = 0.5
a2 = 0.8
plt.scatter(a1, a2, c=[a1+a2], cmap='cool')
plt.colorbar()
plt.show()
This code uses the scatter function from the matplotlib library to plot the point (a1, a2). The c parameter is used to specify the color of the point, which is set to the sum of a1 and a2. The cmap parameter is used to specify the color map to be used for the plot, which is set to 'cool' in this case. Finally, the colorbar function is used to add a color bar to the plot to show the mapping of the color to the value.
You can experiment with different values of a1 and a2 to see how the color changes based on the size of the value
原文地址: https://www.cveoy.top/t/topic/egSg 著作权归作者所有。请勿转载和采集!