0

I have the following variables:

  data = ['10 20 10 36 30 33', 
          '100 50 50 30 60 27 70 24', 
          '300 1000 80 21 90 18 100 15 110 12 120 9',
          '30 90 130 6 140 3']
  data = [e.split() for e in data]

  time = [np.array((time[2::2]), dtype=int) for time in data]
  concentration = [(np.array((concentration[3::2]), dtype=int)) for concentration in data]

I want to plot the variables time(x-value) and concentration(y-value) in a scatterplot diagram, and the where each personson concentration have a different colour. The time and concentration variables are list of arrays, where each array in the list represents a new person.

So i did the following code to plot my variable:

 plt.scatter(time, concentration, color = 'plt.rainbow')

 plt.title('Concentration pr. time')
 plt.legend(loc='upper right') 
 plt.xlabel('Time')
 plt.ylabel('Concentration') 
 plt.grid(True) 

 plt.show()

But this code does not work, i get the following error:

 ValueError: 'color' kwarg must be an color or sequence of color specs. For a sequence of values to be color-mapped, use the 'c' argument instead.

How do i plot my arrays, with their own colors.

Kimdey
  • 11
  • 5
  • have u tried simply changing `color` to `c` as suggested in the error – ombk Dec 01 '20 at 14:09
  • https://stackoverflow.com/questions/12236566/setting-different-color-for-each-series-in-scatter-plot-on-matplotlib check this – ombk Dec 01 '20 at 14:10
  • Maybe remove quotes from color: ` plt.scatter(time, concentration, color = plt.rainbow)` – IoaTzimas Dec 01 '20 at 14:20

0 Answers0