color-mapping

Event Connections and subplots in matplotlib

感情迁移 提交于 2019-12-10 20:32:23
问题 I have what seems to be a simple task yet I am not sure how and where to start. What I currently have is a series of subplots displayed on one figure. Now I want to add/connect an event handler on each subplot, such that when the user clicks on one of the subplots the plot that was selected would be opened in a separate figure/window. I want to know if this is possible and if someone could formulate a small simple code to illustrate how this can be done. I should also mention that the only

Position colorbar inside figure

主宰稳场 提交于 2019-12-06 20:27:38
问题 I have a simple scatter plot where each point has a color given by a value between 0 and 1 set to a chosen colormap. Here's a MWE of my code: import matplotlib.pyplot as plt import numpy as np import matplotlib.gridspec as gridspec x = np.random.randn(60) y = np.random.randn(60) z = [np.random.random() for _ in range(60)] fig = plt.figure() gs = gridspec.GridSpec(1, 2) ax0 = plt.subplot(gs[0, 0]) plt.scatter(x, y, s=20) ax1 = plt.subplot(gs[0, 1]) cm = plt.cm.get_cmap('RdYlBu_r') plt.scatter

Heat map generator of a floor plan image

感情迁移 提交于 2019-12-05 20:31:51
I want to generate a heat map image of a floor. I have the following things: A black & white .png image of the floor A three column array stored in Matlab. -- The first two columns indicate the X & Y coordinates of the floorpan image -- The third coordinate denotes the "temperature" of that particular coordinate I want to generate a heat map of the floor that will show the "temperature" strength in those coordinates. However, I want to display the heat map on top of the floor plan so that the viewers can see which rooms lead to which "temperatures". Is there any software that does this job?

Recording/playback Kinect with Matlab - upside down and in black/white rather than gray scale

老子叫甜甜 提交于 2019-12-05 09:27:13
问题 I am trying to write a program to record and playback both colour and depth streams from a xbox kinect to ease testing image processing programs. Currently I have the bulk done and the colour stream works fine. I am however having trouble with the depth stream. Currently, the depth stream is playing back upside down and only in black and white. I have 3 thoughts as to why this may be the case: 1) The conversion to 8-bit from 11-bit 2) the Motion JPEG 2000 format (never used this before) 3)

Position colorbar inside figure

假如想象 提交于 2019-12-05 01:37:41
I have a simple scatter plot where each point has a color given by a value between 0 and 1 set to a chosen colormap. Here's a MWE of my code: import matplotlib.pyplot as plt import numpy as np import matplotlib.gridspec as gridspec x = np.random.randn(60) y = np.random.randn(60) z = [np.random.random() for _ in range(60)] fig = plt.figure() gs = gridspec.GridSpec(1, 2) ax0 = plt.subplot(gs[0, 0]) plt.scatter(x, y, s=20) ax1 = plt.subplot(gs[0, 1]) cm = plt.cm.get_cmap('RdYlBu_r') plt.scatter(x, y, s=20 ,c=z, cmap=cm) cbaxes = fig.add_axes([0.6, 0.12, 0.1, 0.02]) plt.colorbar(cax=cbaxes, ticks=

Transparent colormap

萝らか妹 提交于 2019-12-04 07:01:48
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) This is a bug with the Colormap class of matplotlib. It exists in 0.99.x versions of matplotlib, but has been fixed as of 1.x. See the bug fix for a description of how it

Problems with zeros in matplotlib.colors.LogNorm

孤街醉人 提交于 2019-12-03 06:37:57
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! tacaswell 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_cmap('gray')) # copy the default cmap my_cmap.set_bad((0,0,0)) plt.imshow(data, norm=matplotlib

Create a color generator from given colormap in matplotlib

感情迁移 提交于 2019-12-03 02:04:48
问题 I have a series of lines that each need to be plotted with a separate colour. Each line is actually made up of several data sets (positive, negative regions etc.) and so I'd like to be able to create a generator that will feed one colour at a time across a spectrum, for example the gist_rainbow map shown here. I have found the following works but it seems very complicated and more importantly difficult to remember, from pylab import * NUM_COLORS = 22 mp = cm.datad['gist_rainbow'] get_color =

Python 3d scatterplot colormap issue

▼魔方 西西 提交于 2019-12-01 19:54:57
I have four dimensional data (x, y, z displacements; and respective voltages) which I wish to plot in a 3d scatterplot in python. I've gotten the 3d plot to render, but I want to have the colour of the points change using a colourmap, dependent upon the magnitude of the point's voltage. I've tried a few things, but can't seem to get it to work I'm getting the error ValueError: Cannot convert argument type <type 'numpy.ndarray'> to rgba array . I'm not sure exactly how to convert what I need to convert, so if anybody could please offer some help, I'd be most appreciative. My code is here: fig =

Matlab custom colormap with only 3 colors

蓝咒 提交于 2019-12-01 13:37:00
just want to check if it is possible to make a custom colormap with only 3 colors? (there is no need for gradient). Example: Data ranges from 0-100 , so 0-33 is one color, 34-67 is another color, and 68-100 is another color. Just use a colormap with three rows. Each row defines a color in terms of R, G, B components. A = randi(100,16,16); %// example data imagesc(A) %// display matrix as image colormap([1 0 0; 0 1 0; 0 0 1]) %// apply colormap colorbar %// show color bar This defines uniformly spaced thresholds between colors. If you need more control you need to have more than three rows,