I am trying to create a scatter plot with x and y grid where every point gets a color by a preassigned value:
{x: 1, y: 2, value: n}
I have a list of x and y and another list for the values, tried using this:
# make range of x(0 - 359) and y(-90 - 90)
x, y = np.meshgrid(range(0, 360), range(-90, 90))
colors = [a very long list (64800 values, one for each point)]
print(colors)
plt.scatter(x, y, c=colors)
plt.colorbar()
plt.show()
Errors:
Traceback (most recent call last): File "C:\python3.6.6\lib\site-packages\matplotlib\colors.py", line 158, in to_rgba rgba = _colors_full_map.cache[c, alpha] KeyError: (1.0986122886681098, None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\python3.6.6\lib\site-packages\matplotlib\axes\_axes.py", line 4210, in scatter colors = mcolors.to_rgba_array(c) File "C:\python3.6.6\lib\site-packages\matplotlib\colors.py", line 259, in to_rgba_array result[i] = to_rgba(cc, alpha) File "C:\python3.6.6\lib\site-packages\matplotlib\colors.py", line 160, in to_rgba rgba = _to_rgba_no_colorcycle(c, alpha) File "C:\python3.6.6\lib\site-packages\matplotlib\colors.py", line 211, in _to_rgba_no_colorcycle raise ValueError("Invalid RGBA argument: {!r}".format(orig_c)) ValueError: Invalid RGBA argument: 1.0986122886681098 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:/Users/amit neumark/Documents/עמית/alpha/grbs data/grbs/find_burst_location.py", line 168, in <module> main() File "C:/Users/amit neumark/Documents/עמית/alpha/grbs data/grbs/find_burst_location.py", line 161, in main ra2, dec2 = chi_square(model, relations) File "C:/Users/amit neumark/Documents/עמית/alpha/grbs data/grbs/find_burst_location.py", line 33, in chi_square create_plot(sums) File "C:/Users/amit neumark/Documents/עמית/alpha/grbs data/grbs/find_burst_location.py", line 134, in create_plot plt.scatter(x, y, c=colors) File "C:\python3.6.6\lib\site-packages\matplotlib\pyplot.py", line 2793, in scatter verts=verts, edgecolors=edgecolors, data=data, **kwargs) File "C:\python3.6.6\lib\site-packages\matplotlib\__init__.py", line 1785, in inner return func(ax, *args, **kwargs) File "C:\python3.6.6\lib\site-packages\matplotlib\axes\_axes.py", line 4223, in scatter .format(nc=n_elem, xs=x.size, ys=y.size) ValueError: 'c' argument has 64800 elements, which is not acceptable for use with 'x' with size 64800, 'y' with size 64800.

