colormap

Change default colorbar for 3D scatter plot with matplotlib

跟風遠走 提交于 2021-02-19 08:25:19
问题 I have 3d coordinates defining positions of points in my 3D scatter plot with a corresponding number of values who I want to create a colour scale for representing the range of values as such: from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') xs,ys,zs = np.random.random(50),np.random.random(50),np.random.random(50) values = np.random.random(50)*10 p = ax.scatter3D(xs, ys, zs=zs, c=values) cbar = fig.colorbar(p) cbar.cmap(plt.cm.Greys)

color coding using scalar mappable in matplotlib

好久不见. 提交于 2021-02-19 04:27:17
问题 is a subplot I created using matplotlib. Is it possible to code the colors on the basis of a pre-defined range? I want to pass an additional parameter, voltage to the function drawLoadDuration and define a scale (using if-else construct?) that sets the color. Higher the voltage, darker the shade. Also, for some reason, the y-tick labels for the colorbar are not showing. Any lead is most welcome...Thanks! import matplotlib.cm from pylab import * import numpy as np f, (ax1, ax2, ax3) = plt

How to control colorbar color ranges in Matlab plots?

让人想犯罪 __ 提交于 2021-02-19 04:27:06
问题 I have the following code: [X,Y,Z] = peaks(30); crange = 1.5; [maxval dummy] = max(Z(:)); [minval dummy] = min(Z(:)); % green, yellow, red cmap = [0 1 0; 1 1 0; 1 0 0]; figure colormap(cmap); surf(X,Y,Z); caxis([30 55]); cbh=colorbar; set(cbh,'Ytick',[30 32 38 55]); My goal is to set the limits of the color bar so that the colors are like this: green from 30 to 32 yellow from 32 to 38 red from 38 to 55 I believe I should somehow change the CData variable, so I used these lines of code without

How to control colorbar color ranges in Matlab plots?

∥☆過路亽.° 提交于 2021-02-19 04:27:05
问题 I have the following code: [X,Y,Z] = peaks(30); crange = 1.5; [maxval dummy] = max(Z(:)); [minval dummy] = min(Z(:)); % green, yellow, red cmap = [0 1 0; 1 1 0; 1 0 0]; figure colormap(cmap); surf(X,Y,Z); caxis([30 55]); cbh=colorbar; set(cbh,'Ytick',[30 32 38 55]); My goal is to set the limits of the color bar so that the colors are like this: green from 30 to 32 yellow from 32 to 38 red from 38 to 55 I believe I should somehow change the CData variable, so I used these lines of code without

Rendering a float array to 24-bit RGB image (using PIL for example)

醉酒当歌 提交于 2021-02-18 11:44:09
问题 x is a numpy.float32 array, with values from -200 to 0 . These are dB (decibel) values. When I do (as recommended here): Image.fromarray(x, mode='F') I get a greyscale or sometimes nearly black image. How to map a float in [-200, 0] to a 24-bit RGB byte array (using a colormap) that can be read with the Python module PIL with Image.fromarray(x, mode='RGB') ? Edit: The required .wav audio file is here, for which we want to plot the spectrogram. Here is some code to test: import scipy, numpy as

Plotting bar charts with a colormap legend

可紊 提交于 2021-02-08 11:42:44
问题 Consider the following: import matplotlib.pyplot as plt from matplotlib import cm import numpy as np y = np.array([1, 4, 3, 2, 7, 11]) colors = cm.hsv(y / float(max(y))) plot = plt.scatter(y, y, c = y, cmap = 'hsv') plt.clf() plt.colorbar(plot) plt.bar(range(len(y)), y, color = colors) plt.show() I want to colormap legend to appear on the top right of the graph (much smaller of course). My image at the moment looks rather clunky as the colormap is clashing somewhat with the actual bars.

Matplotlib: GRID and COLORMAP with TRISURF

流过昼夜 提交于 2021-01-29 20:50:50
问题 I want to put a grid on my surface but it doesn't work even with linewidth different from zero, also I would like to plot a colormap that changes the color with Z axis, so the walls should appear with the same color cos they are points at 0.5 in Z. Hope somebody can help me, thanks. This is the part of my code I'm having problem with: fig = plt.figure() ax = Axes3D(fig) surf = ax.plot_trisurf(x, y, z, cmap=plt.cm.get_cmap('jet',4), shade=False,linewidth=0.1, antialiased=False ) This is my

Matplotlib: GRID and COLORMAP with TRISURF

前提是你 提交于 2021-01-29 17:56:46
问题 I want to put a grid on my surface but it doesn't work even with linewidth different from zero, also I would like to plot a colormap that changes the color with Z axis, so the walls should appear with the same color cos they are points at 0.5 in Z. Hope somebody can help me, thanks. This is the part of my code I'm having problem with: fig = plt.figure() ax = Axes3D(fig) surf = ax.plot_trisurf(x, y, z, cmap=plt.cm.get_cmap('jet',4), shade=False,linewidth=0.1, antialiased=False ) This is my

Matplotlib: How to change colorbar gradient using user input

巧了我就是萌 提交于 2021-01-29 07:09:19
问题 I want to customize the colorbar(colormap) with specific value range. The color range should varies with the given parameter (Tup,Tmd,Tbt) where Tup: User selected Upper value Tmid: User selected Mid Point Tbt:User selected bottom point Mid color (lime) should range through user selected Tup and Tbt with Tmd as a mid-point. I tried to generate custom colormap using below code snippet, but could not able to control its range using user provided values. cmap = LinearSegmentedColormap.from_list(

Replace colors in colormap (python 3.7)

假装没事ソ 提交于 2021-01-28 12:20:19
问题 I use a simple line to break an indexed image 256 color into palette using import numpy as np from PIL import Image im = Image.open('') palette = np.array(im.getpalette(),dtype=np.uint8).reshape((256,3)) ##################### Printed result [[ 1 3 0] [ 2 4 1] [ 28 0 4] [ 20 2 26] [ 24 5 18] [ 33 7 22] [ 36 7 12] [ 0 20 18] [ 42 15 16] [ 43 18 30] ... etc Printing 'palette' lists the colors as RGB values as listed from index 0 onward. Index 0 is often dark color or black. In some engines it is