[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Coloring grid spaces in a 2D by index
From: |
Pantxo |
Subject: |
Re: Coloring grid spaces in a 2D by index |
Date: |
Wed, 3 Jul 2019 15:43:19 -0500 (CDT) |
BGreen wrote
> 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);
> colormap(ax1,discrete_clrmp);
> ax2 = axes(fig);
> colormap(ax2,redblue_clrmp);
>
> data = round(4*rand(100));
> pcolor(ax1,data);
> view(2)
> continuousdata = rand(23);
> pcolor(ax2,continuousdata)
> view(2)
IIUC you have data points in the range [1 2] and for some reason some of
them
are tagged 3 or 4:
## The original data
data = rand (100) + 1;
data(rand(100) < 0.1) = 3;
data(rand(100) < 0.1) = 4;
## The colormap you want
nlev = 50;
redblue = [linspace(0,1,nlev)',zeros(nlev,1),fliplr(linspace(0,1,nlev))'];
cmap = [redblue; 0 1 0; 1 0.5 0];
## Now manipulate the data for plotting
data(data == 3) = nlev + 1;
data(data == 4) = nlev + 2;
data(data<3) = (data(data<3) - 1) * (nlev-1) + 1;
imshow (data, cmap, "xdata", (-10:10), "ydata", (-10:10))
HTH,
Pantxo
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
- Coloring grid spaces in a 2D by index, BGreen, 2019/07/02
- Re: Coloring grid spaces in a 2D by index, Carlo De Falco, 2019/07/02
- Re: Coloring grid spaces in a 2D by index, Brett Green, 2019/07/02
- Re: Coloring grid spaces in a 2D by index, Brett Green, 2019/07/02
- Re: Coloring grid spaces in a 2D by index, Brett Green, 2019/07/02
- Re: Coloring grid spaces in a 2D by index,
Pantxo <=
- Re: Coloring grid spaces in a 2D by index, Brett Green, 2019/07/03
- Re: Coloring grid spaces in a 2D by index, Pantxo Diribarne, 2019/07/03
- Re: Coloring grid spaces in a 2D by index, Brett Green, 2019/07/03
- Re: Coloring grid spaces in a 2D by index, Pantxo Diribarne, 2019/07/05
- Re: Coloring grid spaces in a 2D by index, Pantxo, 2019/07/03