I have a nice two parameter Lyapunov Diagram that I'm plotting using matplotlib. These diagrams take quite a long time to run so in order to run in a short period of time one must compromise in the accuracy. Thus my "zero" is between -0.05 and +0.05. So when Im generating the image I want it to be black for values between -0.05 and 0.05. Below is my attempt so far. I am currently using the the colormap 'flag' for zero but Im not a bit happy with it.
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from numpy import *
dataZ = np.loadtxt("Lyapunov.txt")
dataZ = dataZ[::-1,:]
dataX = np.linspace(0,100,200)
dataY = np.linspace(-110, 110, 200)
X, Y = np.meshgrid(dataX, dataY)
#So we have dataZmin to -0.05 then -0.05 to 0.05 then 0.05 to dataZmax
dZmin = dataZ.min()
dZmax = dataZ.max()
d1 = -0.05 - dZmin
d2 = 0.05 - -0.05
d3 = dZmax - 0.05
dd = 0.1
N1 = int(d1/dd)
N2 = int(d2/dd)
N3 = int(d3/dd)
# sample the colormaps that you want to use. Use 128 from each so we get 256
# colors in total
colors3 = plt.cm.gnuplot(np.linspace(0, 1, N3))
colors2 = plt.cm.flag(np.linspace(0, 1, N2))
colors1 = plt.cm.YlGnBu(np.linspace(0, 1, N1))
# combine them and build a new colormap
colors = np.vstack((colors1, colors2, colors3))
mymap = mcolors.LinearSegmentedColormap.from_list('my_colormap', colors)
plt.imshow(dataZ, cmap=mymap)
plt.colorbar()
plt.show()
For those interested here is the diagram. If anyone has a idea for a better color scheme Id love to know.
Thanks.