I want to define my own ticks in a DateListPlot
. It works quite well when I use the code in a Mathematica Notebook but breaks somehow when using it via Mathematica's script engine.
First of all the code:
Clear[fticks,plot];
fticks[min_, max_] :=
Module[{nTicks = 9}, Table[{min + i (max - min)/nTicks,
DateString[
DateList[min + i (max - min)/nTicks], {"Month", ".", "Year"}]
}, {i, 1, nTicks - 1}]];
plot = DateListPlot[
FinancialData["IBM", "Jan. 1, 2004"],
FrameTicks -> {fticks, Automatic, None, None}
]
Export[FileNameJoin[{$HomeDirectory, "test-plot.png"}], plot];
In my fticks
function I generate some ticks depending on the min
and max
values of the DateListPlot
. This can't be completely wrong since the result works quite well.
But as soon as I try to calculate it via the Mathematica script engine, the custom ticks fail. (I've saved the code above in a file located at ~/test.m
as Mathematica uses *.m
files for its scripting engine).
/Applications/Mathematica.app/Contents/MacOS/MathKernel -script ~/test.m
The result comes without any ticks but a red overlay because of an error. The question is now why is it not working? Interesting is also that while editing the test.m
file there is also the possibility to run the package. I don't know why but this also works.
I work in Mathematica 9.0.1.0 running on Mac OS X 10.8. This error also occurs in Mathematica 8 as I've tested.
Thanks in advance for your help.
;
after theplot = ...
command. $\endgroup$;
and it still doesn't work. $\endgroup$