
Hence it seems import matplotlib.pyplot as plt

If instead all markers are to be of the same color, one can easily use plot instead. Scatter is mainly useful if you want to have differently colored or sized markers. You will then need to either choose a custom color cycle or define the colors and loop over them anyways. So if there is a chance that n becomes larger than 10, the premise not to define any colors yourself breaks down. Matplotlib's default color cycle has 10 colors. You want to have n different colors where n is unknown a priori. Extending this to n arrays, the nth array plotted is also always the same color (where n could be very large).Īs an example, if we consider a simple plot using filled colors, we see that the first 3 plots are always the same color (blue, orange, green), and even when a 4th plot is added the first 3 plots retain their original colors.Ĥ plots, with the original 3 plots retaining their original colors as in the first image aboveĮDIT: As an aside, does anyone know the reason behind not including edgefaces (that would then allow us to easily use default pyplot colors) when setting facecolors='none'? It seems like a rather strange design choice. So for example, if I have 3 arrays, then the first array to be plotted is always color 'x', the second is always color 'y' and the third is always color 'z'. I could use plt.scatter(x, y, s=50, marker='s',facecolors='none',edgecolor=np.random.rand(3,))Īs I've seen answered on this SO, but this is not ideal, as I'm hoping to have deterministic colors between runs.
#PYTHON SCATTER PLOT COLORS SERIES#
However, since my actual data will consist of a variable number of arrays, with the actual number being unknown before runtime, I'm looking to plot each data series in the same scatter plot and with different colors, but without having to explicitly specify what colors to use. Then I do indeed see a series of data plots represented by unfilled red squares, but the downside is that I have to explicitly set what color I want using edgecolor. If I instead use plt.scatter(x, x**2, s=50, marker='s',facecolors='none',edgecolors='r') Which unfills the square markers, but does not leave any marker edges, so no output is actually seen.

To that end, I tried using the following code: import matplotlib.pyplot as plt

I'm trying to produce a series of scatter plots with square and unfilled markers for each data point, with different but deterministic marker colors between runs, for each array.
