Skip to main content

notebooks - NotebookEvaluate with InsertResults -> True from the command line


Suppose I have a notebook template.nb like this:


enter image description here


and I want to evaluate this notebook from the command line. So I wrote this Mathematica script:


UsingFrontEnd[NotebookEvaluate["C:\\Users\\delfinog\\Desktop\\template.nb", 
InsertResults -> True]]

And I run the script like this (Windows 7):



enter image description here


C:> "C:\Program Files\Wolfram Research\Mathematica\10.2\wolfram.exe" -script C:\Users\delfinog\Desktop\mma-script.wl

My expectation is that I should be getting this:


enter image description here


but instead, I get this:


enter image description here


This is the complete output cell


Graphics[{{{}, {}, {Directive[Opacity[1.], RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6]], Line[{{2.040816326530612*^-8, 2.040816326530612*^-8}, {0.000306717908041361, 0.000306717908041361}, {0.0006134154079194566, 0.0006134154079194566}, {0.001226810407675648, 0.001226810407675648}, {0.002453600407188031, 0.002453600407188031}, {0.004907180406212797, 0.004907180406212797}, {0.009814340404262328, 0.009814340404262328}, {0.01962866040036139, 0.01962866040036139}, {0.040908355415730624, 0.040908355415730624}, {0.060777881089422996, 0.060777881089422996}, {0.08025764554305448, 0.08025764554305448}, {0.10138846501985709, 0.10138846501985709}, {0.12110911515498282, 0.12110911515498282}, {0.1424808203132797, 0.1424808203132797}, {0.16346276425151565, 0.16346276425151565}, {0.18303453884807477, 0.18303453884807477}, {0.204257368467805, 0.204257368467805}, {0.22407002874585835, 0.22407002874585835}, {0.24349292780385082, 0.24349292780385082}, {0.2645668818850144, 0.2645668818850144}, {0.28423066662450114, 0.28423066662450114}, {0.305545506387159, 0.305545506387159}, {0.32647058492975595, 0.32647058492975595}, {0.34598549413067603, 0.34598549413067603}, {0.36715145835476726, 0.36715145835476726}, {0.3869072532371816, 0.3869072532371816}, {0.40831410314276706, 0.40831410314276706}, {0.42933119182829166, 0.42933119182829166}, {0.4489381111721394, 0.4489381111721394}, {0.4701960855391582, 0.4701960855391582}, {0.49004389056450015, 0.49004389056450015}, {0.5095019343697813, 0.5095019343697813}, {0.5306110331982336, 0.5306110331982336}, {0.550309962685009, 0.550309962685009}, {0.5716599471949555, 0.5716599471949555}, {0.5926201704848412, 0.5926201704848412}, {0.6121702244330499, 0.6121702244330499}, {0.6333713334044297, 0.6333713334044297}, {0.6531622730341328, 0.6531622730341328}, {0.6725634514437749, 0.6725634514437749}, {0.6936156848765882, 0.6936156848765882}, {0.7132577489677245, 0.7132577489677245}, {0.7345508680820321, 0.7345508680820321}, {0.7544338178546627, 0.7544338178546627}, {0.7739270064072324, 0.7739270064072324}, {0.7950712499829733, 0.7950712499829733}, {0.8148053242170373, 0.8148053242170373}, {0.8361904534742725, 0.8361904534742725}, {0.8571858215114467, 0.8571858215114467}, {0.8767710202069441, 0.8767710202069441}, {0.8980072739256126, 0.8980072739256126}, {0.9178333583026043, 0.9178333583026043}, {0.937269681459535, 0.937269681459535}, {0.9583570596396369, 0.9583570596396369}, {0.978034268478062, 0.978034268478062}, {0.9783774827142147, 0.9783774827142147}, {0.9787206969503675, 0.9787206969503675}, {0.9794071254226728, 0.9794071254226728}, {0.9807799823672838, 0.9807799823672838}, {0.9835256962565057, 0.9835256962565057}, {0.9890171240349493, 0.9890171240349493}, {0.989360338271102, 0.989360338271102}, {0.9897035525072548, 0.9897035525072548}, {0.9903899809795602, 0.9903899809795602}, {0.9917628379241712, 0.9917628379241712}, {0.994508551813393, 0.994508551813393}, {0.9948517660495457, 0.9948517660495457}, {0.9951949802856985, 0.9951949802856985}, {0.9958814087580039, 0.9958814087580039}, {0.9972542657026149, 0.9972542657026149}, {0.9975974799387677, 0.9975974799387677}, {0.9979406941749204, 0.9979406941749204}, {0.9986271226472259, 0.9986271226472259}, {0.9989703368833786, 0.9989703368833786}, {0.9993135511195312, 0.9993135511195312}, {0.999656765355684, 0.999656765355684}, {0.9999999795918367, 0.9999999795918367}}]}}}, {DisplayFunction -> Identity, AspectRatio -> GoldenRatio^(-1), Axes -> {True, True}, AxesLabel -> {None, None}, AxesOrigin -> {0, 0}, DisplayFunction :> Identity, Frame -> {{False, False}, {False, False}}, FrameLabel -> {{None, None}, {None, None}}, FrameTicks -> {{Automatic, Automatic}, {Automatic, Automatic}}, GridLines -> {None, None}, GridLinesStyle -> Directive[GrayLevel[0.5, 0.4]], Method -> {DefaultBoundaryStyle -> Automatic, DefaultMeshStyle -> AbsolutePointSize[6], ScalingFunctions -> None}, PlotRange -> {{0, 1}, {0., 0.9999999795918367}}, PlotRangeClipping -> True, PlotRangePadding -> {{Scaled[0.02], Scaled[0.02]}, {Scaled[0.05], Scaled[0.05]}}, Ticks -> {Automatic, Automatic}}]


So the figure is there, but it is not being displayed. Is there a way to make this work? I was thinking that the UsingFrontEnd command should avoid this situation but there seems to be something else missing.


Motivation: I am developing a report generation system that should be running automatically late at night. As the built-in template system does not work well from MathematicaScript (CASE:3432062) and using ScheduledTasks on my interactive Mathematica session has been unreliable, I am exploring using NotebookEvaluate with the InsertResults -> True option as an alternative template system.




Comments

Popular posts from this blog

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Mathematica: 3D plot based on combined 2D graphs

I have several sigmoidal fits to 3 different datasets, with mean fit predictions plus the 95% confidence limits (not symmetrical around the mean) and the actual data. I would now like to show these different 2D plots projected in 3D as in but then using proper perspective. In the link here they give some solutions to combine the plots using isometric perspective, but I would like to use proper 3 point perspective. Any thoughts? Also any way to show the mean points per time point for each series plus or minus the standard error on the mean would be cool too, either using points+vertical bars, or using spheres plus tubes. Below are some test data and the fit function I am using. Note that I am working on a logit(proportion) scale and that the final vertical scale is Log10(percentage). (* some test data *) data = Table[Null, {i, 4}]; data[[1]] = {{1, -5.8}, {2, -5.4}, {3, -0.8}, {4, -0.2}, {5, 4.6}, {1, -6.4}, {2, -5.6}, {3, -0.7}, {4, 0.04}, {5, 1.0}, {1, -6.8}, {2, -4.7}, {3, -1....