For my report, I'm creating a special color plot in jupyter notebook. There are two parameters, x
and y
.
import numpy as np
x = np.arange(-1,1,0.1)
y = np.arange(1,11,1)
with which I compute a third quantity. Here is an example to demonstrate the concept:
values = []
for i in range(len(y)) :
z = y[i] * x**3
# in my case the value z represents phases of oscillators
# so I will transform the computed values to the intervall [0,2pi)
values.append(z)
values = np.array(values) % 2*np.pi
I'm plotting y
vs x
. For each y = 1,2,3,4...
there will be a horizontal line with total length two. For example: The coordinate (0.5,8)
stands for a single point on line 8 at position x = 0.5
and z(0.5,8)
is its associated value.
Now I want to represent each point on all ten lines with a unique color that is determined by z(x,y)
. Since z(x,y)
takes only values in [0,2pi)
I need a color scheme that starts at zero (for example z=0
corresponds to blue). For increasing z the color continuously changes and in the end at 2pi
it takes the same color again (so at z ~ 2pi
it becomes blue again).
Does someone know how this can be done in python?