Add alpha to an existing colormap

I’m not quite sure if this qualifies within “not knowing the inner structure of the colormap”, but perhaps something like this would work to add a linear alpha to an existing colormap? import numpy as np import matplotlib.pylab as pl from matplotlib.colors import ListedColormap # Random data data1 = np.random.random((4,4)) # Choose colormap cmap = … Read more

Set Colorbar Range

Using vmin and vmax forces the range for the colors. Here’s an example: import matplotlib as m import matplotlib.pyplot as plt import numpy as np cdict = { ‘red’ : ( (0.0, 0.25, .25), (0.02, .59, .59), (1., 1., 1.)), ‘green’: ( (0.0, 0.0, 0.0), (0.02, .45, .45), (1., .97, .97)), ‘blue’ : ( (0.0, … Read more

Add alpha to an existing matplotlib colormap

I’m not quite sure if this qualifies within “not knowing the inner structure of the colormap”, but perhaps something like this would work to add a linear alpha to an existing colormap? import numpy as np import matplotlib.pylab as pl from matplotlib.colors import ListedColormap # Random data data1 = np.random.random((4,4)) # Choose colormap cmap = … Read more

How to pick a new color for each plotted line within a figure

I usually use the second one of these: from matplotlib.pyplot import cm import numpy as np #variable n below should be number of curves to plot #version 1: color = cm.rainbow(np.linspace(0, 1, n)) for i, c in zip(range(n), color): plt.plot(x, y, c=c) #or version 2: color = iter(cm.rainbow(np.linspace(0, 1, n))) for i in range(n): c … Read more

Cyclic colormap without visual distortions for use in phase angle plots?

As of matplotlib version 3.0 there are built-in cyclic perceptually uniform colormaps. OK, just the one colormap for the time being, but with two choices of start and end along the cycle, namely twilight and twilight_shifted. A short example to demonstrate how they look: import matplotlib.pyplot as plt import numpy as np # example data: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)