0
votes

I have a list of points (r1,r2) which I am plotting. For these points I have a certain error value 's' associated with each one of them. I want to assign a color with respect to what the error for each point is. For example red for highest error and blue for lowest error and also get a legend showing the range of colors. Can it be done? I have the following piece of code that I am trying:

fig, ax = plt.subplots()

data = scatter(r1, r2, c=s)

ax.set_title('Colormap for errors')
1

1 Answers

0
votes

How about this,

enter image description here


The source code is as follows. Refer to colormaps for more about colormaps.

import numpy as np
import matplotlib.pyplot as plt

x = np.random.rand(100)
y = np.random.rand(100)

plt.scatter(x, y, c=x, cmap='bwr')
plt.colorbar()
plt.show()