MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathematica bug when resolving Contex-names



> Hi,
> 
>   I actually have two questions/bug reports. The first one about
> resolving Contex-names and the other about handling ticks. Please also
> e-mail any answers/replies to  
>    ozan.oktem@foreningssparbanken.se
> 
> Question 1: Bug in the way Mathematica handels Contex-names? 
>  I can't get Mathematica to load packages and resolve Contex-names 
>  in a proper way. Let me illustrate the problem with a simple example: 
>  We start by creating three packages, "a.m", "b.m" and "c.m". 
>  All reside in the following directory (I use Win NT 4.0 with 
>  Mathematica 3.01):
>     C:\users\default\Mathematica\3.0\AddOns\Applications\test
>  The package "a.m" is given by
>       BeginPackage["test`A`"] 
>       procA::usage = "some text"
>       Begin["`Private`"] 
>             procA[x_] := x;
>       End[] 
>       EndPackage[] 
>  The package "b.m", which uses the package "a.m", is given by
>    BeginPackage["test`B`"]
>    procB::usage = "Some text about the routine"
>    Begin["`Private`"]
>    Needs["test`A`"]
>       procB[x_]:=procA[x]+1
>    End[]
>    EndPackage[]
>  Finally, the package "c.m", which uses the package "b.m", is given by
>    BeginPackage["test`C`"]
>    procC::usage = "Some text about the routine"
>    Begin["`Private`"]
>    Needs["test`B`"]
>       procC[list_]:=procB[x]-1
>    End[]
>    EndPackage[]
>  
>  Now, in a Mathematica notebook, let's type
>    In[1]:= <<test`a`
>    In[2]:= procA[x]
>    Out[2]:= x
>  and everything works fine. Also, restarting the kernel and typing 
>    In[1]:= <<test`b`
>    In[2]:= procB[x]
>    Out[2]:= 1+x
>  shows that everything works as expected. However, restarting the
>  kernel and typing 
>    In[1]:= <<test`c`
>    In[2]:= procC[x]
>    Out[2]:= test`C`Private`x
>  shows that something is wrong! It seems that Mathematica can not
>  resolve Contexe-names more than one level. Is this a bug or am 
>  I doing something wrong? Any suggestions are welcomed.

You're doing something wrong, and I don't think it involves contexts. I
am guessing that

procC[list_]:=procB[x]-1

should have been

procC[x_]:=procB[x]-1

It is unusual to see a function definition where the argument is not
used in the definition.

> Question 2: Bug in the way Mathematica handels ticks?  I can not
> understand 
>   the way Mathematica handels ticks in plotting graphics. The following 
>   example illustrates the problem:
>   Ex1: In[1]:=testlist=Table[j,{j,1,5}];
>      
> In[2]:=ListPlot[testlist,Ticks->{{{1,"A"},{2.7,"B"},{5,"C"}},Automatic}]
>   If things were according to the Mathematica book, I would have the
> tickmark "A" 
>   under x=1 on the x-axis, "B" under x=2.7 on the x-axis and "C" under
> x=5 
>   on the x-axis. However, only the ticks for "B" and "C" appear! Even
> more 
>   confusing is the following example:
>   Ex2: In[1]:=testlist=Table[j,{j,1,5}];
>      
> In[2]:=ListPlot[testlist,Ticks->{{{1,"A"},{2.7,"B"},{5,"C"}},Automatic},
> 
>                     PlotRange->{{0,5},Automatic}]
>   Then all ticks appear in their proper places. Thus, the placement of 
>   ticks seems to depend on the PlotRange settings! This is not mentioned
> 
>   in the Mathematica book. Does anybody know exactly how this dependence
> is? 
>   In example 1 above, why is the tickmark "C" placed correctly but "A"
> is not? 
>   Both ticks are at the end of the PlotRange which is [0,5].
>   Finally consider the following example:
>   Ex3: In[1]:=testlist=Table[j,{j,1,5}];
>      
> In[2]:=ListPlot[testlist,Ticks->{{{1,"A"},{2.7,"B"},{5,"C"}},Automatic},
> 
>                     PlotRange->{{0.25,5},Automatic}]
>   Still, "A" is not placed under x=1, even though the PlotRange is
> [0.25,5], 
>   i.e. it contains x=1 which is the position for the ticlmark "A".

ListPlot will by default omit the tick label where the axes cross.
(There are several reasons for this -- the label would otherwise often
be drawn on top of one of the axes, it isn't always obvious which axis
the label refers to, it can be visually distracting to label both axes
at the axis origin, etc.)  There are various ways to get those labels
if you want them, one of which is to move the axis origin somewhere
else, as in

ListPlot[testlist,Ticks->{{{1,"A"},{2.7,"B"},{5,"C"}},Automatic},
                      AxesOrigin -> {3,3}]

Dave Withoff
Wolfram Research



  • Prev by Date: New version of Leibniz available
  • Next by Date: Re: Simple question
  • Prev by thread: Mathematica bug when resolving Contex-names
  • Next by thread: algebraic solutions