[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coloring grid spaces in a 2D by index

From: Brett Green
Subject: Re: Coloring grid spaces in a 2D by index
Date: Tue, 2 Jul 2019 21:19:00 -0400

To superimpose plots with different colormaps, I have to plot them to separate axes and then assign different colormaps to the separate axes. However, the axes have an opaque background. I just checked the documentation for axes(), and although there are properties for transparency, they're currently unused because that functionality has not been implemented yet. I guess that means I need to find another way.

For completeness, here's the code that overlays two axes objects with different colormaps, but will not work for my purposes because they're opaque.

blue = [0,0,1];
red = [1,0,0];
green = [0,1,0];
orange = [1,0.5,0];
purple = [0.75,0,0.75];

discrete_clrmp = [blue;red;green;orange];

redblue_clrmp = [linspace(0,1,100)',zeros(100,1),fliplr(linspace(0,1,100))'];
orangepurple_clrmp = [fliplr(linspace(0,1,100))',fliplr(linspace(0,0.5,100))',linspace(0,0.75,100)'];

fig = figure(3);
ax1 = axes(fig);
ax2 = axes(fig);

data = "">pcolor(ax1,data);
continuousdata = rand(23);

- Brett Green

On Tue, Jul 2, 2019 at 8:16 PM Brett Green <address@hidden> wrote:
It would also be very nice if I could have some areas discretely colored, but others mixed. For example, I would like to keep the blue, red, green and orange regions for minindex(m,j)==1,2,3,4, but the case currently colored black and assigned minindex(m,j)==5 would be better represented as a mixture of red and blue which continuously interpolates between them, as minindex(m,j) takes noninteger values between 1 and 2 (which are the integers which are colored with blue and red).

I've had another idea: superimposing plots with different colormaps. That would allow me to have one colormap with just a few discrete colors in one plot, and then a different colormap for the blue-to-red continuum. I'll try that and send an update if I get something to work.

- Brett Green

On Tue, Jul 2, 2019 at 5:37 PM Brett Green <address@hidden> wrote:
Thank you!

I mentioned in my first question that I had trouble with pcolor, but maybe I can get it to work the way I need if I write a custom colormap with 6 entries. I haven't played with colormaps much, so I'm not sure if it'll work, but I suppose it's worth a shot.

imshow would be good if I could control the axes. I definitely need to have a set of coordinates to go along with the plot, but I didn't see anything about that for imshow in the documentation. Since it's meant for image processing, I didn't really expect anything, though.

- Brett Green

On Tue, Jul 2, 2019 at 3:20 PM Carlo De Falco <address@hidden> wrote:

> Il giorno 02 lug 2019, alle ore 19:48, BGreen <address@hidden> ha scritto:
> I would like to have a grid in which each box is filled with a color
> corresponding to a value. What is the best way to do this?

you may want to try the commands pcolor[1], or imshow[2],
hope this helps,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]