I have a dataframe like this: data =
sample time (h) Voltage
1 1 2.4
1 2 3
1 3 4
1 4 5.1
2 1 2.4
2 2 3.2
2 3 4.2
2 4 5.2
3 1 2.3
3 2 3.3
3 3 4.4
3 4 5.3
I want to make a scatter plot by x=time (h), and y=voltage, and I want to automatically make the label and color. So for example, the data with "sample 1" will be shown in blue, and will be labled 1, and then "sample 2" is red and is labeled 2, and so on... (by the way, I want to use a qualitative colormap like 'Set1'). This is something that I can de by adding "hue" in seaborne, but I want to do it in matplotlib.
This is the code I have:
fig, ax = plt.subplots()
color_labels = data['Sample'].unique()
rgb_values = sns.color_palette("Set2", 8)
color_map = dict(zip(color_labels, rgb_values))
ax.scatter(x='time (h)', y='Voltage', s=50, data=data,
c=data['Sample'].map(color_map))
I appreciate your help