acer

32343 Reputation

29 Badges

19 years, 326 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

This question has been asked on this site several times over the years [eg, 1, 2, 3, 4]. The answers have usually consisted of flipping the 2D plot and forcing the tickmarks.

Another way is to transform it into a 3D plot, and then display with a flipped orientation.

Since 3D plots get rendered quite small by default, I'll throw in a trick to force the displayed size of a 3D plot programatically. The topic of "size" of rendered 3D plots is tricky, and the size of the containing box (which is what this code affects) is just one piece of the puzzle. Other pieces include the stretching/scaling (which can be done programatically by creation/insertion using DocumentTools commands), and the relative axis-ratios (for which I have some code and might find time to post over the coming holidays...).

 

 

 

restart;

f := x->x^2:
P1 := plot(f, 0..10):
P1;

Pnew := plots:-display(plottools:-transform((x,y)->[x,y,1])(P1),
                       orientation=[90,0,180], axes=frame,
                       axis=[thickness=0,tickmarks=[thickness=0]]):

Pnew;

resize3d := proc(P::specfunc(PLOT3D), d::posint:=600)
   :-PLOT3D(remove(type,[op(P)],'specfunc(ROOT)')[],
          ':-ROOT'(':-BOUNDS_X'(0), ':-BOUNDS_Y'(0),
                   ':-BOUNDS_WIDTH'(d),
                   ':-BOUNDS_HEIGHT'(d)));
end proc:

resize3d(Pnew);

 

 

 

Download 3dviewflipped.mw

Here is an example of using the FileDialog Maplets element to select and open an .mw worksheet/document in the running Standard GUI session.

Of course you don't have to use the returned string (filename) for the purpose of opening some file. I figured that was your goal, based on some recent Questions you've made here.

restart;

OpenDialogue := module()
  local maplet, ModuleApply;
  uses Maplets:-Elements;
  maplet := Maplet(FileDialog['FD1'](
    ':-filefilter' = "mw",
    ':-filterdescription' = "Maple Source Files",
    ':-onapprove' = Shutdown( ['FD1'] ),
    ':-oncancel' = Shutdown() ));
  ModuleApply := proc()
    local G;
    G := Maplets:-Display(maplet);
    if G::list and numelems(G)>0 and G[1]<>"" then
      :-Worksheet:-DisplayFile(G[1]):
    end if;
    return NULL;
  end proc;
end module:

OpenDialogue();

 


Download maplefiledialogue.mw
 

With the Standard GUI of either Maple 2015.2 or 2016.1 the conversion from .hdb to .help format fails. That is, some warning is emitted *and* it fails to find its help-topics (including after complete relaunch). 

I'm submitting a bug report. Additional items on the bug ticket include misspelling of "exist" in an error message, and failure on Windows 7 to recognize "My Documents" folder (only "Documents" works).

That aspect of Explore was improved in Maple 2016.

In your Maple 2015 you could do the following as a workaround for your example.

Instead of doing it like this,

restart;
F:=a*x^2:
Explore(plot(F,x=0..10,view=0..100),parameters=[a=1.0 .. 2.0]);

you could do it like this,

restart;
F:=a*x^2:
eval('Explore'('plot'(F,x=0..10,view=0..100),parameters=[a=1.0 .. 2.0]));

acer

It should be possible to roll your own code for this, and having done so make a procedure of it.

I wrote the following rough code very quickly, and it seems to run the same in Maple2016.1 as well as Maple 18.02. You might try it, or make it more robust, or make a procedure out of it...


 

restart;

xml:=:-XMLTools:-ReadFile(cat(kernelopts(':-homedir'),"/mapleprimes/docprop.mw")):

H:=indets(xml,And('specfunc(`_XML_Metadata-tag`)',
                  'satisfies'(u->member(setattribute("name"="Document Properties",
                                                     ':-xml_attribute'),
                                        [op(u)]))))[1];

`_XML_Metadata-tag`("id" = "0", "category" = "<default>", "name" = "Document Properties", "
        ", `_XML_Metadata-attribute`("name" = "Item List", "value" = "true"), "
        ", `_XML_Metadata-attribute`("name" = "Keywords", "value" = "foo,bar,blech"), "
        ", `_XML_Metadata-attribute`("name" = "Author", "value" = "acer"), "
        ", `_XML_Metadata-attribute`("name" = "Title", "value" = "My Title"), "
        ", `_XML_Metadata-attribute`("name" = "Subject", "value" = "test"), "
    ")

H:={map(setattribute,select(type,[op(H)],'specfunc(:-`_XML_Metadata-attribute`)'),NULL)[]}
   minus
   {"id"="0","category"="<default>","name"="Document Properties"};

{`_XML_Metadata-attribute`("name" = "Author", "value" = "acer"), `_XML_Metadata-attribute`("name" = "Subject", "value" = "test"), `_XML_Metadata-attribute`("name" = "Title", "value" = "My Title"), `_XML_Metadata-attribute`("name" = "Item List", "value" = "true"), `_XML_Metadata-attribute`("name" = "Keywords", "value" = "foo,bar,blech")}

map(u->eval(["name","value"],[op(u)]), H);

{["Author", "acer"], ["Subject", "test"], ["Title", "My Title"], ["Item List", "true"], ["Keywords", "foo,bar,blech"]}

 


 

Download getdocprops.mw

(Better to try it from the attached worksheet, than copy-and-paste which might go wrong at the linebreaks.)

acer

The mserver processes (kernel) and the interface (Std Java GUI, or Classic GUI, or TTY commandline) run as distinct processes and are not "self contained" in the way you seem to be suggesting. As separate processes they communicate over sockets.

acer

sum((-1)^n, n = 1 .. infinity, formal);

                       -1/2

kernelopts(version);

   Maple 2016.1, X86 64 LINUX, Apr 22 2016, Build ID 1133417

See also the Help topic updates,Maple2016,compatibility .

acer

No it is not really possible to use the Maple GUI in that way.

As a one-off endeavour you could in theory construct a complicated system (using Maplets, embedded components, or what have you) that mimics the effects you describe. Or you could crudely wrap all your sectioned code in conditionals tied to semaphores that you set centrally. But those kinds of things need manual set up, are one-offs that need re-doing for each project, and usually need expert input in order to look and work well.

Have you considered the 3rd party Maple IDE ? 

Personally I find keeping complicated source code for involved projects in text files (not worksheets) to be a much better idea. They can be linked into a package using `read` or $include or $define directives. Code changes can be managed and reviewed with standard revision control applications. External text editors often provide excellent support for code editing. Plaintext is much more resilient to file corruption.

You've asked about this before. The next time you choose to discuss it could you please add it here as followup discussion, instead of starting another thread?

acer


 

restart;

with(IterativeMaps):
with(ImageTools):

f := x*exp(r1*(1-a11*x-a12*y)):
g := y*exp(r2*(1-a21*x-a22*y)):

eqs := eval([f,g], [a11=1,a12=2,a21=3,a22=4,r2=1]);

[x*exp(r1*(-x-2*y+1)), y*exp(-3*x-4*y+1)]

Bif:=Bifurcation( [x,y], eqs,
                       ':-rvariable' = r1,
                       ':-xmin'=-0.5, ':-xmax'=4,
                       [0.5,0.5], -1.5, 5,
                       ':-height'=600, ':-width'=600 ):

ColouringProcedures:-HueToRGB( Bif ):

Embed( Bif );


 

Download bifexamp.mw

I used ImageTools:-Write to export the Image to a .bmp format file. I then used a third party tool to convert the saved .bmp file to .gif, so that I could inline it below.

acer

Try this edited version of the file. It was missing several closing Section tags and the closing Worksheet tag.

Alle_opgaver_fixed.mw

acer

There are several syntax errors with your posted code, and your colorfunc's return values don't seem (to me) to fit a documented format. So it's hard to see what your after.

Your construction of p and g could be done more simply using plots:-densityplot, I think. And that command might be able to serve for your second part too, I suspect.

Let me know if this is on the right tack:

restart;

F := proc(x,y)
  local ans;
  #ans := evalf(argument(f(x+I*y))/2/Pi);
  ans := Re(f(x+I*y));
  if ans > evalf(2*Pi) then
    return 0.0;
  else
    return evalf(ans/2/Pi);
  end if;
end proc:

f := tan;

P2 := plots:-densityplot(F, -5..5, -5..5, colorstyle=HUE,
                       style=surface, axes=none, restricttoranges):

H:=plottools:-transform((u,v)->[sech(u)*cos(v),
                                sech(u)*sin(v),
                                u - tanh(u)]):

H(P2);

acer

The procedure SetBackground below changes the pixels that are "dark enough" (eg, black).

The command ImageTools:-Write can be used to write images (as created and understoof by ImagesTools commands) to files.

The code below is 1-D plaintext Maple Notation. It may not paste well directly as 2D Input. (See also the attached worksheet.) The images below look better in Maple. The export to .bmp produces a much better result, also using ImageTools:-Write, but I can't upload such files directly to this site.

restart;
Logistic := IterativeMaps:-Bifurcation([x], [r*x*(1-x)], [.5], 2.5, 4,
                        height=300, width=300):
ImageTools:-ColouringProcedures:-HueToRGB(Logistic):
ImageTools:-Embed(Logistic);
#ImageTools:-Write(cat(kernelopts(homedir),"/mapleprimes/im1.jpg"),
#                  Logistic):

SetBackground:=proc(A::Array, C::string)
  local i,p,T;
  uses ImageTools;
  if not type(A,'Array(:-datatype=float[8])') then
    error "expecting an Image for the first argument";
  end if;
  if nops([op(2,A)])<>3 then
    error "expecting a color Image with exactly three layers";
  end if;
  p:=[ColorTools:-Color(C)[]];
  for i from 1 to 3 do
    T[i]:=Threshold(FitIntensity(ToGrayscale(A)),0.001,
                    method=both,low=p[i],high=0.0);
    T[i]:=T[i]+GetLayer(A,i);
  end do;
  CombineLayers(T[1],T[2],T[3]);
end proc:

new1 := SetBackground(Logistic, "Teal"):
ImageTools:-Embed(new1);
#ImageTools:-Write(cat(kernelopts(homedir),"/mapleprimes/im2.jpg"),
#                  new1):

new2 := SetBackground(Logistic, "Gray"):
ImageTools:-Embed(new2);
#ImageTools:-Write(cat(kernelopts(homedir),"/mapleprimes/im3.jpg"),
#                  new2):

SetBack.mw

acer

Another possibility that works nicely here is specification of the particular contours as a list of numeric values. Eg,

plots:-contourplot( -(1/2)*y^2-(1/2)*x^2-(1-.3)/sqrt((x+.3)^2+y^2)
                    +((-1)*.3)/sqrt((x-1+.3)^2+y^2),
                    x=-2.25..2.25, y=-2.25..2.25, axes=boxed,
                    contours=[seq(-2.5..-1.3,0.1)], grid=[80,80],
                    coloring=["Niagara Azure","Orange"] );

acer

If you intend on pasting it somewhere else as plaintext then you should consider also setting interface(prettyprint=1). That will allow you to retain the formatting (multiple lines of text, with indenting). If you cut and paste the 2D Output of the printed procedure body then it may get pasted in elsewhere as one single long line.

interface(prettyprint=3): # the Standard GUI default
interface(verboseproc=1): # the default

print(Plot:-PointPlot); # displays only the elided body

interface(verboseproc=3): # allow the full body
kernelopts(opaquemodules=false); # printing of module locals

print(Plot:-PointPlot:-ModuleApply);

interface(prettyprint=1): # formatted plaintext printing

print(Plot:-PointPlot:-ModuleApply);

acer

On some machines Maple's Standard GUI has trouble with the rendering of spacecurves unless the linestyle option is specified. Does the following work for you?

restart;
with(DEtools):

DEplot3d({diff(y(x), x) = y(x)-z(x), diff(z(x), x) = z(x)-2*y(x)},
         {y(x), z(x)}, x = 0 .. 3, [[y(0) = 1.638, z(0) = 2.31]],
         y = 0 .. 2, z = -4 .. 4, scene = [x, z(x), y(x)],
         linecolor = COLOR(HUE, .5), linestyle=solid);

acer

First 202 203 204 205 206 207 208 Last Page 204 of 336