acer

32727 Reputation

29 Badges

20 years, 90 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Carl Love Thanks, Carl.

I'm going to try again to push for contourplot and listcontplot to get augmented with most of the useful functionality we've discussed. (I've submitted several requests, and now I may have to send some reminders. Plotting is so important!)

I think that it's important to offer the following bits of functionality, preferably within one single command such as plots:-contourplot. I'd like it if attaining the variants didn't require users' having to strip out CURVES with subsindets or any other fancy techniques.

1) One related thing I've noticed with contourplot is that the filled regions' boundaries can really benefit visually from a boundary curve, so that the edges don't appear jagged. Some people want black or other monochromatic contour curves between shaded regions. But some people might want the boundaries to simply match one neighboring region along the boundary. Both could be readily available.

2) Some people will prefer a smooth gradient, as densityplot supplies. And some might prefer discretely shaded regions such as are shown in the Answer above.

3) The colorscheme option would allow for more control of the variation in the contours and the shaded regions, as shown above.

4) I'd like to see legends on 2D contour plots, with the same flexibility as the hover-over contour labels have. (And why not legends for 3D curves or surfaces that have a single color or style? That could be useful for 3D contour plots.)

I'll leave aside color-bars for now, as constructing them for all manner of custom colorings and shading schemes, for both 3D and 2D, can get quite involved. (There are many relevent posts that could be linked for this. But also, this is relevent to more than just contour plots.)

I'm torn about inlined text labels on contour lines. This post shows that it can look very impressive, and it's a popular request. But I suspect that the ideal solution is to have the contour values be stored (like the hover-over values) in a new substructure on the CURVES. That way the GUI could, dynamically, both place and render them best, as plots are zoomed or magnified. And those aspects can be trickier still if gaps in the curves are desired for spots for the text labels.

And of course there may be things to fix. I've reported the following densityplot flip more than once (it was fixed only for colorscheme, but not for colorstyle).

plots:-densityplot(x,x=0..1,y=0..1,colorstyle=HUE,style=surface);
plots:-densityplot(x,x=0..1,y=0..1,colorstyle=HUE,style=surface,restricttoranges);

And I'm not sure why the following currently shades the same way as "ygradient" (it's shaded by z-value in Maple 18.02),

L:=[seq([i,1,evalf(sin(Pi*i))],i=0.0..1.0,0.05)]:
plots:-pointplot3d(A, symbolsize=20, symbol=solidsphere,
                   colorscheme=["zgradient",["Red","Yellow","Blue"]],
                   labels=[x,y,z], orientation=[-1,90,-1]);

 

@phiost And you're not going to mention which version you're using?!

Also, do you want hue apread such as in a rainbow, or the ability to get exactly that one given colorscheme, or the ability to match any colorscheme, or...?

I edited my Answer to work in versions back to Maple 18.02. (I only tested the latest point-release for each major version. There is some funny business in changes to the color Arrays generated, and your mileage may vary with other point-releases...)

@phiost But you have only mentioned that you want a 2D plot. You have left other important details unspecified.

note: I should add that I submitted a Software Change Request two years ago for the plots:-contourplot command to offer the full colorscheme functionality. (I also submitted a few other suggestions related to coloring and contourplot and listcontplot . They have not yet been implemented.)

You have posted what, now, three or four Questions about either colored contour plots and/or paremetric or implicit plots of a certain system? It is counter-productive and unhelpful to not state what you really want up front.

In this last question you don't even bother to tell us whether you want a 2D or 3D result, what or how many contour values, whether it should allow for `filledregions`, and whether you intend on apply some technique to an explicit expression as above or some other parametric or implicit plot.

I don't necessarily have the spare time to try and produce what you want in many separate steps. If you update this Question with a Comment that contains what you're really after, as the final kind of plotting result, then I may find spare time to provide an answer.

@phiost Your transformation is producing floats with 0.0*I artefacts.

You could have discovered this by trying it out for a few values. Eg,

evalf( eval([x,t],[X=-2,t=4]) );
                    [2.805755396 + 0. I, 4.]

You could try this,

P2D1 :=plots:-display(
  plottools:-transform((a,b)->eval([Re(evalf(x)),t],[X=a,t=b]))(Pft),
  labels=["x","t"]
);

phiost_2.mw

@saemi123 Why didn't you provide your example when you first asked the Question!?!?

More importantly what you show is ambiguous 2D Input. Either upload the example in an attached .mw worksheet or show it as unambiguous 1D plaintext code.

ps. you might just utilize yhe `unapply` command to define X, instead of that ambiguous 2D Input assignment.

@phiost Yes.

Suppose you have any 2D plot assigned to the name P.

Then the following will turn it into a 3D plot in the level plane z=17. (And of course you can use z=-1 or any other value for z.)

plottools:-transform((x,y)->[x,y,17])(P);

And you can use plots:-display to combine multiple 3D plots.

Here is a zip file of a .mw file example,  contour_labels_transformed_B.zip . It creates all the plots below. If you want some other variant on these effects then please just describe it in full detail.

The first plot below has the contour labels at the same z-value as the level curves, which are placed slightly above the level surface. The text is hard to see unless the surface has a transparency, but that make it look washed out compared to the 3D surface above it. The 3D surface doesn't have the contour-lines style that the other two plots below have, but that can be changed.

And here it is in 3D without the contour labels.

It seems that for 3D a better effect can be obtained by raising the contour labels (text) above both the level curves and the corresponding level surface.I think this looks best, although you might experiment with a color other than red for the text (contour labels).

The plots:-shadebetween command was introduced in Maple 2015 and not Maple 15 (released 2011), and so will not be present in Maple 18 (released 2014).

The naming scheme changed in the year 2015, with versions since then named according to the year in which they were released.

Try this attachment in your Maple 18 ,

between_18.mw

 

Since not everyone has an updated Physics package that can handle this example could you please show the result of applying lprint to sol?

I suspect that sol is a call something like `&where(foo, bar) and if so then you should be able to evaluate (or otherwise substitute) the equations in bar into the expression foo.

And while evalf(Int(..., n=1..infinity)) can sometimes be handled numerically, if may not always converge fast enough. In that case you could make a very targeted substitution of a number for infinity using subsindets which would be safer than a blanket substitution.

@nm I suspect that Joe intended an effect something more like that of the following:

if op([5,1],ToInert(eval(`latex/int`)))
     = _Inert_IF(_Inert_CONDPAIR(
                  _Inert_INEQUAT(_Inert_NARGS(),_Inert_INTPOS(2)),
                   _Inert_STATSEQ(_Inert_ERROR(_Inert_STRING("invalid arguments"))))) then
  `latex/int`:=FromInert(subsop([5,1]=NULL,ToInert(eval(`latex/int`))));
end if:

Did you consider that the plot of Im(z) versus s might depend on Re(z)?

The discrepancy appears to be fixed in Maple 2019.1, in the sense that the weights Y used in computations like Mean(X, weights = Y) are used in the same manner when performed by DataSummary.

In Maple 2018.0 (through to Maple 2019.1) I see the following improvement: Just one preliminary conversion required, although the original arcsin form remains.

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

x1 := arcsin(1/2*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2));

arcsin((1/2)*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2))

convert(x1,expln);
simplify(%);

-I*ln(((1/2)*I)*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2)+(1/2)*(2-(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2))

(15/32)*Pi

convert(x1,arctan);
simplify(%);

2*arctan((2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2)/(2+(2-(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2)))

(15/32)*Pi

simplify(x1);

arcsin((1/2)*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2))

 

Download simplification_example.mw

And an additional example mentioned below by vv also works directly:

restart;
arctan(-sqrt(2)-1+sqrt(2-sqrt(2))+sqrt(2+sqrt(2))):

simplify(%);
                             1    
                             -- Pi
                             16   

@mmcdara In my Maple 2019.1 the computation of Variance(Z(X+Y)) completes, slowly, under these assumptions on sigma__x and sigma__y.

It also sometimes completes without assumptions, if interrupted and re-computed. That's a sign that int is struggling. An important difficulty is that in nested/iterated form int(int(int(...))) the inner integrals are not aware that the outer variables of integration may be real, or lie within a specific range, etc.

But using the so-called collapsed form int(...,[...]) it computes reasonably quickly under those same assumptions.

I will submit another Software Change Request, to the effect that Statistics should probably use that collapsed form for all its multiple intergals -- whether active or inert.

The same goes for VectorCalculus:-int and Student:-MultivariateCalculus:-MultiInt. (I have a growing collection of simple examples where it makes the difference between success versus failure, or a quick versus a slow computation.)

So, for now, value(CollapseNested(Combine( some_inert_nested_integral ))) can be a useful alternative.

restart:

kernelopts(version);

`Maple 2019.1, X86 64 LINUX, May 21 2019, Build ID 1399874`

with(Statistics): with(IntegrationTools):

X := RandomVariable(Normal(mu__x, sigma__x)):
Y := RandomVariable(Normal(mu__y, sigma__y)):

U := X+Y:
Z := q -> cos(q):
v__z := Variance(Z(X)):
V := subs({mu__x=Mean(U), sigma__x=StandardDeviation(U)}, v__z);

-(1/2)*(2*cos(mu__x+mu__y)^2*exp(sigma__x^2+sigma__y^2)-2*cos(mu__x+mu__y)^2-exp(2*sigma__x^2+2*sigma__y^2)+1)*exp(-2*sigma__x^2-2*sigma__y^2)

bar := CollapseNested(Combine(Variance(Z(X+Y),inert))):

raw1 := CodeTools:-Usage( value(bar) ) assuming sigma__x>0, sigma__y>0;

memory used=349.05MiB, alloc change=76.00MiB, cpu time=3.69s, real time=3.41s, gc time=478.88ms

(1/4)*(-exp(sigma__x^2+sigma__y^2)-2*exp((2*I)*mu__x+sigma__x^2+sigma__y^2+(2*I)*mu__y)+2*exp(2*sigma__x^2+(2*I)*mu__x+(2*I)*mu__y+2*sigma__y^2)+exp((4*I)*(mu__x+mu__y))-exp((4*I)*mu__x+(4*I)*mu__y+sigma__x^2+sigma__y^2)+1)*exp(-2*sigma__x^2-(2*I)*mu__x-(2*I)*mu__y-2*sigma__y^2)

S1 := simplify(evalc(simplify(raw1)));
is(S1=V);

(1/2)*(-cos(2*mu__x+2*mu__y)-1)*exp(-sigma__x^2-sigma__y^2)+(1/2)*exp(-2*sigma__x^2-2*sigma__y^2)*cos(2*mu__x+2*mu__y)+1/2

true

raw3 := CodeTools:-Usage( Variance(Z(X+Y)) ) assuming sigma__x>0, sigma__y>0;

memory used=5.68GiB, alloc change=345.59MiB, cpu time=55.16s, real time=50.86s, gc time=7.13s

-(1/4)*(exp(sigma__x^2+sigma__y^2)+2*exp((2*I)*mu__x+sigma__x^2+sigma__y^2+(2*I)*mu__y)-2*exp(2*sigma__x^2+(2*I)*mu__x+(2*I)*mu__y+2*sigma__y^2)-exp((4*I)*(mu__x+mu__y))+exp((4*I)*mu__x+(4*I)*mu__y+sigma__x^2+sigma__y^2)-1)*exp(-2*sigma__x^2-(2*I)*mu__x-(2*I)*mu__y-2*sigma__y^2)

S3 := simplify(evalc(simplify(raw3)));
is(S3=V);

(1/2)*(-cos(2*mu__x+2*mu__y)-1)*exp(-sigma__x^2-sigma__y^2)+(1/2)*exp(-2*sigma__x^2-2*sigma__y^2)*cos(2*mu__x+2*mu__y)+1/2

true

 

Download stats_example.mw

@qilianshan In your input you can type Ctrl-L to insert such an equation label reference.

First 220 221 222 223 224 225 226 Last Page 222 of 599