Hi All,
I have been trying to use pcolor for plotting but have had no success
for the past whole week. For example, if b1 and b2 are variables from
the numerical solution of a pde then I set
parameter1=linspace(.....);
parameter2=linspace(.....);
loop for parameter 1 and 2
D=b1-b2;
find(D<0)
pcolor(parameter1,parameter2, when is D negative )
Basically I want it to give the plot a green color if D is negative
only in the region 0<x<25, blue if D is negative only in 25<x<50,.....
and so on.
I very much appreciate it if someone can shed some light on this, as I
have been trying all week to get it right but no hope.
Cheers,
Emma
|
|
0
|
|
|
|
Reply
|
MA87 (38)
|
6/1/2010 4:14:57 PM |
|
FRUITS wrote:
> I have been trying to use pcolor for plotting but have had no success
> for the past whole week. For example, if b1 and b2 are variables from
> the numerical solution of a pde then I set
>
> parameter1=linspace(.....);
> parameter2=linspace(.....);
>
> loop for parameter 1 and 2
>
> D=b1-b2;
> find(D<0)
>
> pcolor(parameter1,parameter2, when is D negative )
>
> Basically I want it to give the plot a green color if D is negative
> only in the region 0<x<25, blue if D is negative only in 25<x<50,.....
> and so on.
You are trying to mix two modes of pcolor. pcolor() can color a matrix
on your behalf according to value if you give it only the matrix of
values; in that case that you supply x and y coordinates, then you must
supply a color value for each coordinate pair and so must pre-compute
the appropriate color values yourself.
What shape is D? is it length(parameter1) by length(parameter2) ?
|
|
0
|
|
|
|
Reply
|
Walter
|
6/1/2010 4:33:04 PM
|
|
On Jun 1, 5:33=A0pm, Walter Roberson <rober...@hushmail.com> wrote:
> FRUITS wrote:
> > I have been trying to use pcolor for plotting but have had no success
> > for the past whole week. =A0For example, if b1 and b2 are variables fro=
m
> > the numerical solution of a pde then I set
>
> > parameter1=3Dlinspace(.....);
> > parameter2=3Dlinspace(.....);
>
> > loop for parameter 1 and 2
>
> > D=3Db1-b2;
> > find(D<0)
>
> > pcolor(parameter1,parameter2, when is D negative )
>
> > Basically I want it to give the plot a green color if D is negative
> > only in the region 0<x<25, blue if D is negative only in 25<x<50,.....
> > and so on.
>
> You are trying to mix two modes of pcolor. pcolor() can color a matrix
> on your behalf according to value if you give it only the matrix of
> values; in that case that you supply x and y coordinates, then you must
> supply a color value for each coordinate pair and so must pre-compute
> the appropriate color values yourself.
>
> What shape is D? is it length(parameter1) by length(parameter2) ?
Thanks for replying. Here is my basic code
param1s=3Dlinspace(....);
param2s=3Dlinspace(....);
Ldiff=3D[];
for j=3D1:length(param1s)
pars.param1=3Dparam1s(j);
for i=3D1:length(param2s)
pars.param2=3Dparam2s(i);
"run" my other program successively with those param1 and 2
D=3Db1-b2;
Ldiff(i,j)=3Dlength(find(D<0));
end
end
pcolor(param1s,param2s,double(Ldiff>0))
However, this is general and does NOT incorporate each range of x
(spatial variable) where D is negative a different colour.
|
|
0
|
|
|
|
Reply
|
FRUITS
|
6/1/2010 4:53:18 PM
|
|
FRUITS <MA87@HOTMAIL.CO.UK> wrote in message <8eb9f4b5-feb1-4fd4-88b7-2dfcfd77085c@v37g2000vbv.googlegroups.com>...
> Hi All,
>
> I have been trying to use pcolor for plotting but have had no success
> for the past whole week. For example, if b1 and b2 are variables from
> the numerical solution of a pde then I set
>
> parameter1=linspace(.....);
> parameter2=linspace(.....);
>
> loop for parameter 1 and 2
>
> D=b1-b2;
> find(D<0)
>
> pcolor(parameter1,parameter2, when is D negative )
>
> Basically I want it to give the plot a green color if D is negative
> only in the region 0<x<25, blue if D is negative only in 25<x<50,.....
> and so on.
>
> I very much appreciate it if someone can shed some light on this, as I
> have been trying all week to get it right but no hope.
>
> Cheers,
>
> Emma
a hint:
help patch;
us
|
|
0
|
|
|
|
Reply
|
us
|
6/1/2010 4:54:04 PM
|
|
On Jun 1, 5:54=A0pm, "us " <u...@neurol.unizh.ch> wrote:
> FRUITS <M...@HOTMAIL.CO.UK> wrote in message <8eb9f4b5-feb1-4fd4-88b7-2df=
cfd770...@v37g2000vbv.googlegroups.com>...
> > Hi All,
>
> > I have been trying to use pcolor for plotting but have had no success
> > for the past whole week. =A0For example, if b1 and b2 are variables fro=
m
> > the numerical solution of a pde then I set
>
> > parameter1=3Dlinspace(.....);
> > parameter2=3Dlinspace(.....);
>
> > loop for parameter 1 and 2
>
> > D=3Db1-b2;
> > find(D<0)
>
> > pcolor(parameter1,parameter2, when is D negative )
>
> > Basically I want it to give the plot a green color if D is negative
> > only in the region 0<x<25, blue if D is negative only in 25<x<50,.....
> > and so on.
>
> > I very much appreciate it if someone can shed some light on this, as I
> > have been trying all week to get it right but no hope.
>
> > Cheers,
>
> > Emma
>
> a hint:
>
> =A0 =A0 =A0help patch;
>
> us
....but I am sure it can be done in pcolor rather than patch.
|
|
0
|
|
|
|
Reply
|
FRUITS
|
6/1/2010 5:11:13 PM
|
|
FRUITS wrote:
> On Jun 1, 5:33 pm, Walter Roberson <rober...@hushmail.com> wrote:
>> What shape is D? is it length(parameter1) by length(parameter2) ?
> Thanks for replying. Here is my basic code
> D=b1-b2;
You have not indicated the shape of b1 or b2, so I cannot tell what
shape D is ?
> pcolor(param1s,param2s,double(Ldiff>0))
Please be more specific about how you want to color the areas where D is
non-negative.
> Ldiff(i,j)=length(find(D<0));
Ldiff(i,j) = any(D<0);
would be more efficient.
> pcolor(param1s,param2s,double(Ldiff>0))
Your pcolor has param1s in the first argument, the one for x, but your
double for loop indexes param1s in the outer loop, j, which you use as
the second index of Ldiff, which is normally the position used for y
rather than x. If the lengths of param1s and param2s are not the same,
then this will cause your pcolor() call to fail.
As you referenced x as being the variable you wanted to vary the color
over, we need you to be clearer about whether that is the first or
second index of Ldiff.
|
|
0
|
|
|
|
Reply
|
Walter
|
6/1/2010 5:17:44 PM
|
|
On Jun 1, 6:17=A0pm, Walter Roberson <rober...@hushmail.com> wrote:
> FRUITS wrote:
> > On Jun 1, 5:33 pm, Walter Roberson <rober...@hushmail.com> wrote:
> >> What shape is D? is it length(parameter1) by length(parameter2) ?
> > Thanks for replying. =A0Here is my basic code
> > =A0 =A0 =A0 =A0 D=3Db1-b2;
>
> You have not indicated the shape of b1 or b2, so I cannot tell what
> shape D is ?
>
sorry, b1 and b2 are the numerical solutions of my pde and when
plotted against x at steady state they look like a quadratic function.
> =A0> pcolor(param1s,param2s,double(Ldiff>0))
>
> Please be more specific about how you want to color the areas where D is
> non-negative.
I want to loop through "my other program" using param1(i) and
param2(j) and see if b1-b2 is becoming negative anywhere in my spatial
domain as the parameters are changing. param(i) is varying for
example from 0 to 100 in 100 steps ... etc
>
> =A0> Ldiff(i,j)=3Dlength(find(D<0));
>
> Ldiff(i,j) =3D any(D<0);
>
> would be more efficient.
>
> =A0> pcolor(param1s,param2s,double(Ldiff>0))
>
> Your pcolor has param1s in the first argument, the one for x, but your
> double for loop indexes param1s in the outer loop, j, which you use as
> the second index of Ldiff, which is normally the position used for y
> rather than x.
thanks for pointing that out, I will double check it.
If the lengths of param1s and param2s are not the same,
> then this will cause your pcolor() call to fail.
>
The lengths are the same. The pcolor is working, but it is not
exactly how I want it to present the results.
> As you referenced x as being the variable you wanted to vary the color
> over, we need you to be clearer about whether that is the first or
> second index of Ldiff.
maybe this is not so clear. The pcolor I want is param1 vs param2 vs
where D is negative.
Specifically, I want to include in the code not only if D is negative
or not, but where in the spatial domain is it negative. E.g, If it is
negative where x<(somevalue) then colour it blue. If it is negative
where x>(somevalue) then colour it red....etc
Note: I am not plotting x in the pcolor...x is only involved in my
"other program" that solves the set of pdes.
I hope it is a bit clearer now, thanks.
|
|
0
|
|
|
|
Reply
|
FRUITS
|
6/1/2010 5:48:05 PM
|
|
FRUITS wrote:
>> Please be more specific about how you want to color the areas where D is
>> non-negative.
> I want to loop through "my other program" using param1(i) and
> param2(j) and see if b1-b2 is becoming negative anywhere in my spatial
> domain as the parameters are changing. param(i) is varying for
> example from 0 to 100 in 100 steps ... etc
You indicated that when 0 < x < 25, you want negative values to be green, and
when 25 < x < 50, you want negative values to be blue. Now suppose I find a
point for which 0 < x < 25, but the point has no associated negative values:
what color should the point be colored? What if the point with no negative
values where in 25 < x < 50, then what color should it be colored? What if the
point has associated negative values but for the point, x is 25 _exactly_ and
thus does not fall into either the green region (which needs less than 25) nor
the blue region (which needs more than 25) ?
>> As you referenced x as being the variable you wanted to vary the color
>> over, we need you to be clearer about whether that is the first or
>> second index of Ldiff.
>
> maybe this is not so clear. The pcolor I want is param1 vs param2 vs
> where D is negative.
>
> Specifically, I want to include in the code not only if D is negative
> or not, but where in the spatial domain is it negative. E.g, If it is
> negative where x<(somevalue) then colour it blue. If it is negative
> where x>(somevalue) then colour it red....etc
>
> Note: I am not plotting x in the pcolor...x is only involved in my
> "other program" that solves the set of pdes.
Do I understand correctly that x is a variable involved in the section you
marked as "run my program with these parameters" ? That after that section of
code, we can count on x having a value? If so, then is x relatively easily
predictable based on the parameters (which might allow us to color sections of
the array at one time), or should x be treated as "sufficiently magic" in the
parameters that we should just do the color selection point by point?
|
|
0
|
|
|
|
Reply
|
Walter
|
6/1/2010 7:40:18 PM
|
|
On Jun 1, 8:40=A0pm, Walter Roberson <rober...@hushmail.com> wrote:
> FRUITS wrote:
> >> Please be more specific about how you want to color the areas where D =
is
> >> non-negative.
> > I want to loop through "my other program" using param1(i) and
> > param2(j) and see if b1-b2 is becoming negative anywhere in my spatial
> > domain as the parameters are changing. =A0param(i) is varying for
> > example from 0 to 100 in 100 steps ... etc
>
> You indicated that when 0 < x < 25, you want negative values to be green,=
and
> when 25 < x < 50, you want negative values to be blue. Now suppose I find=
a
> point for which 0 < x < 25, but the point has no associated negative valu=
es:
> what color should the point be colored? What if the point with no negativ=
e
> values where in 25 < x < 50, then what color should it be colored? What i=
f the
> point has associated negative values but for the point, x is 25 _exactly_=
and
> thus does not fall into either the green region (which needs less than 25=
) nor
> the blue region (which needs more than 25) ?
This is exactly what I want to do. I want to give any negative values
that happen to occur in the region 0 <=3D x <=3D 25 a specific color
(say,green), (as long as the negative points are in the region, it
does not matter how many negative points I have - i.e the length),
and the ones in the region 25 <=3D x <=3D 50 another color and 0 <=3D x <=
=3D
50 (ie. the whole x domain) another color.
If I dont have any negative values in any region I also want to give
it another color...so, in total I need to assign 4 different colors to
4 different cases.
I think it is fairly straightforward to implement, but I have had no
hopes with it so far. Maybe someone can enlighten me, Thanks!
>
> >> As you referenced x as being the variable you wanted to vary the color
> >> over, we need you to be clearer about whether that is the first or
> >> second index of Ldiff.
>
> > maybe this is not so clear. The pcolor I want is param1 vs param2 vs
> > where D is negative.
>
> > Specifically, I want to include in the code not only if D is negative
> > or not, but where in the spatial domain is it negative. =A0E.g, If it i=
s
> > negative where x<(somevalue) then colour it blue. =A0If it is negative
> > where x>(somevalue) then colour it red....etc
>
> > Note: I am not plotting x in the pcolor...x is only involved in my
> > "other program" that solves the set of pdes.
>
> Do I understand correctly that x is a variable involved in the section yo=
u
> marked as "run my program with these parameters" ? That after that sectio=
n of
> code, we can count on x having a value? If so, then is x relatively easil=
y
> predictable based on the parameters (which might allow us to color sectio=
ns of
> the array at one time), or should x be treated as "sufficiently magic" in=
the
> parameters that we should just do the color selection point by point?
yes, x is just a spatial independent variable of the pde.
|
|
0
|
|
|
|
Reply
|
FRUITS
|
6/2/2010 12:07:48 AM
|
|
FRUITS wrote:
> This is exactly what I want to do. I want to give any negative values
> that happen to occur in the region 0 <= x <= 25 a specific color
> (say,green), (as long as the negative points are in the region, it
> does not matter how many negative points I have - i.e the length),
> and the ones in the region 25 <= x <= 50 another color and 0 <= x <=
> 50 (ie. the whole x domain) another color.
>
> If I dont have any negative values in any region I also want to give
> it another color...so, in total I need to assign 4 different colors to
> 4 different cases.
We are getting closer, but I do not understand the bit about the whole x
domain. You appear to be saying that when 0 <= x < 25, that you want to
color the point both the first color _and_ the third color, since 0 <= x
< 25 is also part of the range 0 <= x <= 50; likewise, 25 < x <= 50
should be colored both the second and third color, and 25 exactly, which
falls under all three conditions, should be all three colors simultaneous.
|
|
0
|
|
|
|
Reply
|
Walter
|
6/2/2010 3:25:13 AM
|
|
On Jun 2, 4:25=A0am, Walter Roberson <rober...@hushmail.com> wrote:
> FRUITS wrote:
> > This is exactly what I want to do. =A0I want to give any negative value=
s
> > that happen to occur in the region =A00 <=3D x <=3D 25 a specific color
> > (say,green), (as long as the negative points are in the region, it
> > does not matter how many negative points I have - i.e the length),
> > and the ones in the region 25 <=3D x <=3D 50 another color and 0 <=3D x=
<=3D
> > 50 (ie. the whole x domain) another color.
>
> > If I dont have any negative values in any region I also want to give
> > it another color...so, in total I need to assign 4 different colors to
> > 4 different cases.
>
> We are getting closer, but I do not understand the bit about the whole x
> domain. You appear to be saying that when 0 <=3D x < 25, that you want to
> color the point both the first color _and_ the third color, since 0 <=3D =
x
> < 25 is also part of the range 0 <=3D x <=3D 50; likewise, 25 < x <=3D 50
> should be colored both the second and third color, and 25 exactly, which
> falls under all three conditions, should be all three colors simultaneous=
..
Let me say that again. I loop through my "other program" using
params1 and params2.
If D is ALWAYS negative in the region from x=3D0 to x=3D50 (and say 50 is
the end of the spatial domain)
then I would give it a specific color.
If D is negative ONLY from x=3D0 to x=3D25 then I give it another color.
If D is negative ONLY from x=3D25 to x=3D50 then I give it another color.
If D is non-negative anywhere then I give it another color.
I just want to know how to color these regions using pcolor.
Please let me know if you need any clarifications.
|
|
0
|
|
|
|
Reply
|
FRUITS
|
6/2/2010 10:19:27 AM
|
|
FRUITS wrote:
> Let me say that again. I loop through my "other program" using
> params1 and params2.
> If D is ALWAYS negative in the region from x=0 to x=50 (and say 50 is
> the end of the spatial domain)
> then I would give it a specific color.
>
> If D is negative ONLY from x=0 to x=25 then I give it another color.
>
> If D is negative ONLY from x=25 to x=50 then I give it another color.
>
> If D is non-negative anywhere then I give it another color.
Is it the case that at each step, x is a vector of values, each in the
range 0 to 50 and that D is the same length as x, with each element of D
corresponding to the x in the same position? If so, then is x always a
full vector from 0 to 50, or does it sometimes cover only part of that
range? Is 25 certain to be at the mid-point of the vector of x? Is x
sorted in ascending order?
If x _is_ a vector of values ranging from 0 to 50, and if you want the
colors to be determined point-wise, then please clarify which color you
would want for the following cases:
- No D are negative
- some but not all D corresponding to 0 to 25 are negative, and no D
corresponding to 25 to 50 are negative
- all D corresponding to 0 to 25 are negative, and no D corresponding to
25 to 50 are negative
- no D corresponding to 0 to 25 are negative, and some but not all D
corresponding to 25 to 50 are negative
- some but not all D corresponding to 0 to 25 are negative, and some but
not all D corresponding to 25 to 50 are negative
- all D corresponding to 0 to 25 are negative, and some but not all D
corresponding to 25 to 50 are negative
- no D corresponding to 0 to 25 are negative, and all D corresponding to
25 to 50 are negative
- some but not all D corresponding to 0 to 25 are negative, and all D
corresponding to 25 to 50 are negative
That is 8 possible cases -- more if you wish to detect D equal to 0.
Please also decide (arbitrarily if necessary) which of the two sides you
want x exactly equal to 25 to fall into. It is computationally more
efficient if you have x exactly equal to 25 fall into the first half.
The alternative to all of this is that x is, after each run, a single
value that is in the range 0 to 50, and that you are asking that the
entire graph be colored one color if all of the D are negative at every
iteration, and that each location which ended up with an x from 0 to 25
be colored with a second color if all of the D are negative at those
locations, and that each location which ended up with an x from 25 to 50
be colored with a third color if all of the D are negative at those
locations. This leaves open the question of what colors you would wish
to use if somewhere in the graph, there was a location in which at least
one D was non-negative, and so on.
|
|
0
|
|
|
|
Reply
|
Walter
|
6/2/2010 3:27:30 PM
|
|
|
11 Replies
330 Views
(page loaded in 0.13 seconds)
Similiar Articles: pcolor in Matlab - comp.soft-sys.matlabHi All, I have been trying to use pcolor for plotting but have had no success for the past whole week. For example, if b1 and b2 are variables fr... Please help me produce a nice .eps or .pdf using pcolor - comp ...Hi all, I'm using pcolor (with interpolated shading) to create a figure. My goal is to then use Adobe Illustrator (CS3) to produce a publication-q... Log scaling of colors/colorbar for pcolor plot - comp.soft-sys ...I'm doing a pcolor plot where the Z values range from 0 to 40, but with nearly all the points below being less than 1. I'm wondering if there is a wa... pcolor plot axis - comp.soft-sys.matlabhi, I would like that in a pcolor plot I have performed, the axis (line and axis markers)would be visible (the pcolor plot does not allow to see th... semilog plots with pcolor? - comp.soft-sys.matlabI am trying to plot data with pcolor that is linear in the Y axis but normally distributed to the log of the X axis. To visualize this, I would like ... how to insert topography/continents in pcolor graphs? - comp.soft ...Hi there, I can't figure it out how to insert lands on my matlab plots. I am using pcolor to plot climatological data, like SST or SLP. This is ... plotting a 3D data in plane by color - comp.soft-sys.matlab ...I've found "contourf" function near to my need > but it draws some contour lines in the figure, too. > How can I do this in Matlab? Sounds like pcolor() [Surf-plots]: Removing the grid-lines for visibility - comp.soft ..."Jim Lambaugh" <lambaugh@gmail.com> wrote in message news:htgj78$966$1@fred.mathworks.com... > Hi > > Is it possible to remove the grid-lines in a surf plot > (http ... Numerical solution to two-dimensional reaction diffusion equation ...pcolor in Matlab - comp.soft-sys.matlab Numerical solution to two-dimensional reaction diffusion equation ... I have had a go at coding the problem in Matlab but got ... contourf with squares not interpolated contours? - comp.soft-sys ...pcolor in Matlab - comp.soft-sys.matlab... this is general and does NOT ... Hi all, I'm using pcolor (with interpolated ... I've found "contourf" function near to my need ... Plotting two functions on the same plot - comp.soft-sys.matlab ...Hi all, I want to plot two y-axis data on the same x-axis. The problem is that the first plot should be done using command 'pcolor' and sec... image processing- correlation map - comp.soft-sys.matlab ...pcolor in Matlab - comp.soft-sys.matlab image processing- correlation map - comp.soft-sys.matlab ..... image - comp.soft-sys.matlab ... image processing- correlation map ... Argument must be a valid movie matrix from GETFRAME - comp.soft ...pcolor in Matlab - comp.soft-sys.matlab... to mix two modes of pcolor. pcolor() can color a matrix ... Ldiff>0)) Your pcolor has param1s in the first argument ... problem ... Matlab polar to cartesian with density compensation - comp.soft ...pcolor in Matlab - comp.soft-sys.matlab... density map over a ... image in Cartesian coordinates - comp.soft-sys.matlab ..... to represent the matrix in polar coordinates ... contour figure with three variables - comp.soft-sys.matlab ...pcolor in Matlab - comp.soft-sys.matlab For example, if b1 and b2 are variables from the numerical solution of a ... I've found "contourf" function near to my need > but ... pcolor - Pseudocolor (checkerboard) plot - MathWorks - MATLAB and ...This MATLAB function draws a pseudocolor plot. ... pcolor -Pseudocolor (checkerboard) plot. Alternatives. To graph selected variables, use the Plot Selector in the ... pcolor (MATLAB Functions)pcolor. Pseudocolor plot. Syntax. pcolor(C) pcolor(X,Y,C) pcolor(axes_handle,...) h = pcolor(...) Description. A pseudocolor plot is a rectangular array of cells with ... 7/17/2012 6:49:16 PM
|