what is the Maple equivalent of Matlab's axis ([-inf inf -inf inf]) ?

matlab has the following command:

axis ([-inf inf -inf inf])

where the inf means (something like) "the largest value" and -inf "the smallest value". With this command, you can set the dimension of the axes without having to enter the actual values, which is then robust to changes in parameter values. This is most useful in situations where some of the values are to be fixed and others left to the simulation, say:

axis ([0 inf -inf 1])

What would be the Maple equivalent or workaround?

many thanks.

example?

Do you have a specific example of the effect of that Matlab command?. In this page, I do not see something specific about:

axis ([-inf inf -inf inf])

but just the case of a single "inf".

an example

thanks jakubi,

this is a very good link to the Matlab function, actually.

Let me explain how the inf and -inf can be used. Consider the following:

> xmin:=-2*Pi: xmax:=2*Pi:
> plot(cos(x), x=xmin..xmax);

Maple automatically selects the maximum and minimum values along the y-axis. For this specific example, I can reproduce the look of the plot by doing the following (Maple13/classic):

> ymin:=-1.05: ymax:=1.05:
> plot(cos(x), x=xmin..xmax, view=[xmin..xmax,ymin..ymax]);

I was able to guess by trial and error that Maple selects something like -1.05 and 1.05 as the minimum and maximum values of the y-axis.

If I want to plot the positive quadrant only (for some reason), then I set the ymin and ymax as follows:


> ymin:=0: ymax:=1.05:

But  while I *know* that I want to select ymin:=0, I can only *guess* that I need ymax:=1.05. And if I change some parameters of my function that "optimal" ymax value may change as a result (while my ymin will not)

with Matlab I would have obtained the desired result by setting:

> ymin:=0: ymax:=inf:

Matlab *knows* that the appropriate value of ymax is 1.05 in this case, and automatically selects another value if I change the parameters of my function.

automatic single limit

Yes, this automatic single limit case is clear to me. In fact, I have requested this functionality many years ago... And I think that I have even found some workaround.

But still I do not find clear the case of all four "inf".

example of use

Let me say more perhaps: the purpose for which I'm looking for this functionality is the following. I want to plot two thick lines to be used to overwrite plot axes (a workaround for the inability to customize the axes) and I want to display these lines in any plot of my worksheet, not knowing in advance the different lengths of my plot axes.

So I thought of doing something along the lines of (this is a first shot):

xy := (xmin,xmax,ymin,ymax)-> 
plottools[line]([xmin,0],[xmax,0],thickness=5),
plottools[line]([0,ymin],[ymax],thickness=5):

and then add it to any plot p like

plots[display](p,xy(xmin,xmax,ymin,ymax));

where I don't need to specify the values of xmin,xmax,ymin,ymax because Maple knows them.

I know that Maple knows these values because it actually uses them to display plots for which I don't specify view=[xmin,xmax,ymin,ymax].

I could of course specify the xmin, xmax, etc. manually for each plot. The problem with doing this sort of thing manually is that 1) the xmin, xmax, etc. must be customized for each plot, which takes some tweaking and is time-consuming (presumably the time I spend searching for this functionality and setting it up will eventually be less than the time I would waste tweaking each of a potentially large but currently unknown number of plots to be created over the next few years), 2) I usually use my worksheets to study the effects of changing parameter values; as parameter values change so do the axis lengths.

Perhaps what I'm trying to do can actually done in a more straightforward way. Generally speaking I would certainly be useful to have the ability to extract the values of xmin, xmax, etc. with an inline command similar to inf or -inf; perhaps such a command does exist already?

Thanks jakubi, you're a great help,

Patrick.

min, max

Not sure yet about the case of the abscissa, for a function y(x) say, as normally either you choose the plot interval or let maple use its default (like -10..10)

For the ordinate, though, it is basically a matter of finding min and max for y(x) on that interval. One way to find ymin and ymax is using the lists [x,y] for the plot points in the 'plot' data structure:

p:=plot(cos(x), x=0..2*Pi):
L2:=map(x->op(2,x),op([1,1],p)):
ymax:=max(L2);
ymin:=min(L2); 

                              ymax := 1.

                    ymin := -0.999995190907583154

min max works

Thanks jakubi, so how about this?

> xmin:=-2*Pi: xmax:=2*Pi:
> p:= plot(cos(x), x=xmin..xmax):
> L2:=map(x->op(2,x),op([1,1],p)):
   ymax:=max(L2);
   ymin:=min(L2);

                     ymax := 0.99999999999999988


                     ymin := -0.99999928691950258

> L1:=map(x->op(1,x),op([1,1],p)):
   xmax:=max(L1);
   xmin:=min(L1);

                     xmax := 6.28318529460999998


                     xmin := -6.28318529460999998

it looks like the correct values in the example. I'll try to use that to create generic axes.

map(x->op(2,x),op([1,1],p)) remains esoteric to me even after looking up the map and op help, but it's growing on me! thanks!

but nothing new

But max(L1) and min(L1) just reproduce, in float form, the values xmin:=-2*Pi and xmax:=2*Pi set before. I.e. you do not get anything new by doing that. I had thought that you was looking for something different, but not sure what. 

of course you're right

so let's see how I can use this to achieve my underlying purpose.

purpose: in as little notation as possible, display a plot where the default axis has been overwritten by thicker lines (a workaround for the absence of control over axis thickness).

first attempt: I wrote a procedure (my first such) intended to do the above. It almost works. But not quite. The procedure is called "mydisplay" and is intended to replace the standard plots[display]

mydisplay := proc(p)
   local xy, xmin, xmax, ymin, ymax:
   local L1, L2:
   xmin:=-10: xmax:=10:
   L1:=map(x->op(1,x),op([1,1],p)): xmax:=max(L1): xmin:=min(L1):
   L2:=map(x->op(2,x),op([1,1],p)): ymax:=max(L2): ymin:=min(L2):
   xy := (xmin,xmax,ymin,ymax)-> 
   plots:-display(plottools[line]([xmin,0],[xmax,0],thickness=3), 
   plottools[line]([0,ymin],[0,ymax],thickness=3), 
   view=[xmin..xmax,ymin..ymax]):
   plots:-display({p,xy(xmin,xmax,ymin,ymax)},
   view=[xmin..xmax,ymin..ymax]):
   print(%):
 end proc:

Then, I can call the procedure:

p := plot(cos(x), x=-2*Pi..2*Pi):
mydisplay(p);

This sort of works (tested with Maple13/classic). If I want to control the x-axis, I can modify this part: plot(cos(x), x=-2..2): But it doesn't really work in that I have lost the ability to use the view=[-2..2,-0.5..0.5] option. So I need a procedure that can be used more like the standard call to display.

Is it possible to build a procedure that is a slightly modified version of an existing native Maple command?

view

You mean something like this?:

mydisplay2 := proc(p,l)
    local xy, xmin, xmax, ymin, ymax:
    local L1, L2:
    xmin:=-10: xmax:=10:
    L1:=map(x->op(1,x),op([1,1],p)): xmax:=max(L1): xmin:=min(L1):
    L2:=map(x->op(2,x),op([1,1],p)): ymax:=max(L2): ymin:=min(L2):
    xy := (xmin,xmax,ymin,ymax)-> 
    plots:-display(plottools[line]([xmin,0],[xmax,0],thickness=3), 
    plottools[line]([0,ymin],[0,ymax],thickness=3), 
    view=[xmin..xmax,ymin..ymax]):
    plots:-display({p,xy(op(l))},
    view=[l[1]..l[2],l[3]..l[4]]):
    print(%):
end proc:

p := plot(cos(x), x=-2*Pi..2*Pi):
mydisplay2(p,[-2,2,-0.5,0.5]);

fantastic

EXACTLY what I was after, fantastic jakubi, thanks a lot.

I'm also learning how to build a procedure by studying your code.

thank you,

Patrick.

Draw gridlines over axes

Patrick writes: "I want to plot two thick lines to be used to overwrite plot axes (a workaround for the inability to customize the axes)."

A workaround that doesn't require figuring out the y-axis range is to use custom gridlines. For example, try the following:

> plot(cos(x), x=xmin..xmax, axis=[gridlines=[[0], thickness=4], tickmarks=8], axes=normal);

This produces thick gridlines at x=0 and y=0 only. You have to add a tickmarks suboption because otherwise, Maple assumes that you want tickmarks at the same locations as gridlines by default.

Paulina Chin
Maplesoft

blurred borders

Interesting workaround. However, with thickness=4 I see these thick axes with blurred borders on my screen. They show sharper, with e.g. thickness=5.

Maple 13 Classic GUI

Thanks Paulina, this is a useful thing to know.

The option/gridlines workaround you suggest works for Maple/Standard but not for Maple/Classic. I should have made it clearer that I am interested in using this in Maple/Classic because the axis lines are thinner in classic than in standard, and especially because the 3D plots produced in Maple/Classic actually look a great deal better than the 3D plots produced in Maple/Standard -- something I am hoping Maple 14 will address :-)

Paulina, if you're reading, do you know whether the tickmarks/thickness option available in Maple 11 (still documented in the help, but lost in Maple 13) is unavailable by design or because of a bug? If it's a bug, let's report it as such.

jakubi, do you mean the effect caused by the fact that the gridlines are grey by default while the axis lines are black? The call below sets the gridlines to black and looks alright on my Maple13/Standard:

p := plot(cos(x), x=-2*Pi..2*Pi, 
axis=[gridlines=[[0], thickness=3, color=black], tickmarks=8], axes=normal): 
plots[display](p);

even values

May be because of how grey is generated on screen. May be also an issue of pixels and screen resolution. The fact is that even thickness values, like 2 or 4, produce blurred borders, while for odd ones, like 3 or 5, the borders look sharper.

even values indeed

I see what you mean, I too get that blurred effect for even values on-screen (Maple13/standard), but when I exported as ps, I couldn't see the blur anymore:

p4 := plot(cos(x), x=-2*Pi..2*Pi, 
axis=[gridlines=[[0], thickness=4, color=black], tickmarks=8], axes=normal):
plotsetup(ps,plotoutput=`p4.ps`,
plotoptions=`color,portrait,noborder,axiswidth=500pt,axisheight=500pt`):  
plots[display]({p4},labels=[``,``]);

 

Tickmarks options

Patrick, thanks for pointing out the tickmarks/thickness problem. Indeed, this did work in Maple 11 but is now broken in Maple 13. I'll make sure this problem is added to our bugs database, if it isn't there already, and it will be addressed in a future release. I'm afraid I can't think of a different workaround you can use for the Classic GUI, except for what Alejandro had already suggested.

Paulina

Thanks Paulina

thanks for your help Paulina,

and a big thank you to Alejandro, as always!

Patrick.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}