color-mapping

Set a colormap under a graph

不羁岁月 提交于 2021-02-08 04:22:11
问题 I know this is well documented, but I'm struggling to implement this in my code. I would like to shade the area under my graph with a colormap. Is it possible to have a colour, i.e. red from any points over 30, and a gradient up until that point? I am using the method fill_between, but I'm happy to change this if there is a better way to do it. def plot(sd_values): plt.figure() sd_values=np.array(sd_values) x=np.arange(len(sd_values)) plt.plot(x,sd_values, linewidth=1) plt.fill_between(x,sd

Gnuplot Polar Coodinates Histogram

耗尽温柔 提交于 2021-01-27 18:15:02
问题 I have a data file file.dat with three columns (radio, angle, Temperature) for points in the plane, and I want to plot this data as a histogram using polar coordenates and color maps, like in the figure below but using gnuplot. I can create a histogram.dat file with the values of the bins that I want but I don't know how to plot it in gnuplot 回答1: To my knowledge there is no right-away "polar heatmap" plotting style in gnuplot (but I could be wrong, at least, I haven't seen an example on the

Color-mapping a 3D quiver function using matplotlib

纵饮孤独 提交于 2020-06-22 12:57:30
问题 I have created a lovely 3D displacement vector field in python using Matplotlib and I am happy with the results. However, visually it is not very east to see the magnitude of the displacements only the direction. Is there a way in python that I could use a colour scale for the arrows so that the magnitude of the displacements is clearer/more visible. This is what I have so far #%% Import Libraries from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np #%%

Setting the size of a matplotlib ColorbarBase object

人走茶凉 提交于 2020-01-07 02:48:19
问题 I have an patch collection that I'd like to display a color map for. Because of some manipulations I do on top of the colormap, it's not possible for me to define it using a matplotlib.colorbar instance. At least not as far as I can tell; doing so strips some manipulations I do with my colors that blank out patches lacking data: cmap = matplotlib.cm.YlOrRd colors = [cmap(n) if pd.notnull(n) else [1,1,1,1] for n in plt.Normalize(0, 1)([nullity for _, nullity in squares])] # Now we draw. for i,

Transparent colormap

為{幸葍}努か 提交于 2020-01-01 10:35:47
问题 I would like to get a density distribution plot like this density http://www.nicolacarlon.it/out.png with the alpha channel instead of the blue channel like this density http://www.nicolacarlon.it/out2.png I found this code but it doesn't works :( theCM = cm.get_cmap() theCM._init() alphas = np.abs(np.linspace(-1.0, 1.0, theCM.N)) theCM._lut[:-3,-1] = alphas plt.imshow(img, cmap=theCM) plt.savefig("out.svg", transparent=True) 回答1: This is a bug with the Colormap class of matplotlib. It exists

Problems with zeros in matplotlib.colors.LogNorm

久未见 提交于 2020-01-01 02:44:12
问题 I am plotting a histogram using plt.imshow(hist2d, norm = LogNorm(), cmap = gray) where hist2d is a matrix of histogram values. This works fine except for elements in hist2d that are zero. In particular, I obtain the following image but would like the white patches to be black. Thank you! 回答1: Here's an alternative method that does not require you to muck with your data by setting a rgb value for bad pixels. import copy data = np.arange(25).reshape((5,5)) my_cmap = copy.copy(matplotlib.cm.get

Automatic construction of a colormap around the value zero

痞子三分冷 提交于 2019-12-30 02:16:08
问题 I often want to plot a difference image that ranges from some negative number to some positive one. The issue with that is that matlab's colormaps scale only from the min value to the max value but do not care about some middle value (this case zero). For example, I have produced the peaks image with a single pixel different: where the original looks like this: So zero values are blue at the top image and green at the bottom... (using jet colormap as an example) I'd like to built a colormap

Colormap issue using animation in matplotlib

你离开我真会死。 提交于 2019-12-25 04:09:03
问题 I use matplotlib.animation to animate data in a 3D array named arr . I read data from a h5 file using h5py library and everything is OK. But when using animation, the colormap got stuck in first frame of the data range, and after some steps it shows unnormalized colors while plotting. Here is my code: import numpy as np import h5py import matplotlib.pyplot as plt import matplotlib.animation as animation import matplotlib.cm as cm f = h5py.File('ez.h5','r') arr = f["ez"][:,:,:] f.close() fig =

Colormap issue using animation in matplotlib

一个人想着一个人 提交于 2019-12-25 04:08:02
问题 I use matplotlib.animation to animate data in a 3D array named arr . I read data from a h5 file using h5py library and everything is OK. But when using animation, the colormap got stuck in first frame of the data range, and after some steps it shows unnormalized colors while plotting. Here is my code: import numpy as np import h5py import matplotlib.pyplot as plt import matplotlib.animation as animation import matplotlib.cm as cm f = h5py.File('ez.h5','r') arr = f["ez"][:,:,:] f.close() fig =