In [445]:
# Creating RGB colorbars based on escape time
In [446]:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as col
import matplotlib.cm as cm
In [447]:
def rgb_linear(escapet, rgb_base, rgb_freq):
'''
calculates RGB tuples based on escape time, rgb_base and rgb_freq
'''
red = rgb_base[0]
green = rgb_base[1]
blue = rgb_base[2]
if (rgb_freq[0] > 0 and 255 - red > 0):
red = rgb_base[0] + ((escapet * rgb_freq[0]) % (255 - rgb_base[0]))
#print("red: " + str(red))
if (rgb_freq[1] > 0 and 255 - blue > 0):
green = rgb_base[1] + ((escapet * rgb_freq[1]) % (255 - rgb_base[1]))
#print("green: " + str(green))
if (rgb_freq[2] > 0 and 255 - green > 0):
blue = rgb_base[2] + ((escapet * rgb_freq[2]) % (255 - rgb_base[2]))
#print("blue: " + str(blue))
return (red, green, blue)
In [448]:
escape_time = np.arange(0, 100, 1)
rgb_values_1 = np.zeros((100,3), dtype='uint8')
rgb_values_2 = np.zeros((100,3), dtype='uint8')
rgb_values_3 = np.zeros((100,3), dtype='uint8')
rgb_values_4 = np.zeros((100,3), dtype='uint8')
rgb_values_5 = np.zeros((100,3), dtype='uint8')
rgb_values_6 = np.zeros((100,3), dtype='uint8')
rgb_values_7 = np.zeros((100,3), dtype='uint8')
for et in escape_time:
#rgb_values[et] = np.append(rgb_linear(et, (255, 0, 0), (0, 16, 5.15)), 255)
rgb_values_1[et] = rgb_linear(et, (255, 0, 0), (0, 2, 0))
rgb_values_2[et] = rgb_linear(et, (255, 0, 0), (0, 8, 0))
rgb_values_3[et] = rgb_linear(et, (255, 0, 0), (0, 16, 0))
rgb_values_4[et] = rgb_linear(et, (255, 0, 0), (0, 2, 4))
rgb_values_5[et] = rgb_linear(et, (255, 0, 0), (0, 8, 4))
rgb_values_6[et] = rgb_linear(et, (255, 0, 0), (0, 16, 4))
rgb_values_7[et] = rgb_linear(et, (80, 20, 0), (4, 6, 8))
In [449]:
bounds = np.arange(0, 100, 1)
In [450]:
# create a norm_obj that we can use to normalize our RGB tuples
norm_obj_1 = col.Normalize(vmin=np.amin(rgb_values_1),
vmax=np.amax(rgb_values_1))
norm_obj_2 = col.Normalize(vmin=np.amin(rgb_values_2),
vmax=np.amax(rgb_values_2))
norm_obj_3 = col.Normalize(vmin=np.amin(rgb_values_3),
vmax=np.amax(rgb_values_3))
norm_obj_4 = col.Normalize(vmin=np.amin(rgb_values_4),
vmax=np.amax(rgb_values_4))
norm_obj_5 = col.Normalize(vmin=np.amin(rgb_values_5),
vmax=np.amax(rgb_values_5))
norm_obj_6 = col.Normalize(vmin=np.amin(rgb_values_6),
vmax=np.amax(rgb_values_6))
norm_obj_7 = col.Normalize(vmin=np.amin(rgb_values_7),
vmax=np.amax(rgb_values_7))
In [451]:
colmap_1 = col.ListedColormap(norm_obj_1(rgb_values_1))
colmap_2 = col.ListedColormap(norm_obj_2(rgb_values_2))
colmap_3 = col.ListedColormap(norm_obj_3(rgb_values_3))
colmap_4 = col.ListedColormap(norm_obj_4(rgb_values_4))
colmap_5 = col.ListedColormap(norm_obj_5(rgb_values_5))
colmap_6 = col.ListedColormap(norm_obj_6(rgb_values_6))
colmap_7 = col.ListedColormap(norm_obj_7(rgb_values_7))
In [452]:
norm_1 = mpl.colors.BoundaryNorm(bounds, colmap_1.N)
norm_2 = mpl.colors.BoundaryNorm(bounds, colmap_2.N)
norm_3 = mpl.colors.BoundaryNorm(bounds, colmap_3.N)
norm_5 = mpl.colors.BoundaryNorm(bounds, colmap_4.N)
norm_6 = mpl.colors.BoundaryNorm(bounds, colmap_5.N)
norm_7 = mpl.colors.BoundaryNorm(bounds, colmap_6.N)
norm_7 = mpl.colors.BoundaryNorm(bounds, colmap_7.N)
In [453]:
def one_band_axes():
fig = plt.figure(figsize=(10, 3))
#fig.suptitle("Escape Time Color sequences")
# rect [left, bottom, width, height]
ax_1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
ax_2 = fig.add_axes([0.05, 0.475, 0.9, 0.15])
ax_3 = fig.add_axes([0.05, 0.15, 0.9, 0.15])
cb_1 = mpl.colorbar.ColorbarBase(ax_1, cmap=colmap_1,
norm=norm_1,
boundaries=bounds,
# extend='both',
# Make the length of each extension
# the same as the length of the
# interior colors:
extendfrac='auto',
spacing='uniform',
orientation='horizontal')
cb_1.set_label('rgb-base=255,0,0 rgb-freq=0,2,0')
cb_2 = mpl.colorbar.ColorbarBase(ax_2, cmap=colmap_2,
norm=norm_2,
boundaries=bounds,
# extend='both',
# Make the length of each extension
# the same as the length of the
# interior colors:
extendfrac='auto',
spacing='uniform',
orientation='horizontal')
cb_2.set_label('rgb-base=255,0,0 rgb-freq=0,8,0')
cb_3 = mpl.colorbar.ColorbarBase(ax_3, cmap=colmap_3,
norm=norm_3,
boundaries=bounds,
# extend='both',
# Make the length of each extension
# the same as the length of the
# interior colors:
extendfrac='auto',
spacing='uniform',
orientation='horizontal')
cb_3.set_label('rgb-base=255,0,0 rgb-freq=0,16,0')
#plt.tight_layout()
plt.show()
In [454]:
def two_band_axes():
fig = plt.figure(figsize=(10, 3))
#fig.suptitle("Escape Time Color sequences")
# rect [left, bottom, width, height]
ax_1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
ax_2 = fig.add_axes([0.05, 0.475, 0.9, 0.15])
ax_3 = fig.add_axes([0.05, 0.15, 0.9, 0.15])
cb_1 = mpl.colorbar.ColorbarBase(ax_1, cmap=colmap_4,
norm=norm_4,
boundaries=bounds,
# extend='both',
# Make the length of each extension
# the same as the length of the
# interior colors:
extendfrac='auto',
spacing='uniform',
orientation='horizontal')
cb_1.set_label('rgb-base=255,0,0 rgb-freq=0,2,4')
cb_2 = mpl.colorbar.ColorbarBase(ax_2, cmap=colmap_5,
norm=norm_5,
boundaries=bounds,
# extend='both',
# Make the length of each extension
# the same as the length of the
# interior colors:
extendfrac='auto',
spacing='uniform',
orientation='horizontal')
cb_2.set_label('rgb-base=255,0,0 rgb-freq=0,8,4')
cb_3 = mpl.colorbar.ColorbarBase(ax_3, cmap=colmap_6,
norm=norm_6,
boundaries=bounds,
# extend='both',
# Make the length of each extension
# the same as the length of the
# interior colors:
extendfrac='auto',
spacing='uniform',
orientation='horizontal')
cb_3.set_label('rgb-base=255,0,0 rgb-freq=0,16,4')
#plt.tight_layout()
plt.show()
In [455]:
one_band_axes()
two_band_axes()