I need to use a different colourmap for a range of different sensors. I'm planning to have these different colourmaps in a list that will be called upon in the loop. The individual colourmap for a sensor shows the range of temperatures the sensor was measured over.
So far I am struggling to implement this, I can specify a common colourmap in the loop, here 'Blues' but don't know how to loop over the different colourmaps
cmap = ['Blues', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds']
for j, n in enumerate(sensor_number):
fig = plt.figure(str(n), figsize=[10,6])
for k, T in enumerate(Temp):
xs = np.linspace(t[0], t[-1], 1000)
ys = model_funct(xs, *param[k][j])
plt.plot(xs, ys, label="Standard Linear Model", color='k', linestyle='dashed
cm = plt.cm.Blues(np.linspace(0.5, 0.8, len(Temp)))
for i in range(len(Temp)):
plt.scatter(t, R, s=0.5, label="Experimental Data", color=cm[i])
#plt.savefig(dir + '\\Graphs\\' + str(n) + 'hj.png')
plt.show()
where, t and R is my data
I have simplified and cut a lot of parts out of my code to show the problem, so the code might look a little unnecessary in places.
Also would a contour plot be better for this? Where a different contour is a different temperature
Two example with the colormaps passed around/used as parameters as objects. One is following your approach with a separate fig/colormap for each sensor. But the data might be more understandable if you use one colormap for all, so I've shown how to share a colormap across all the sensors.
A practice that I have strong feelings about, especially for experimental/sensor data: it should always be stored and passed around with all its identifiers, metadata, however you want to think about it. Everything you could need to reconstruct where it came from. Build it in anywhere you can -- the datastructures that write sensor data to file, the filenames of images, tiny-text captions that you can crop off for publication but are always "really" there... anything. It is so easy to get scrambled and not too hard to set yourself up once so that you automatically label everything. Make the computer do the boring repetitive parts!
From the first approach:
Shared colorbar: