2
$\begingroup$

Requires MaTeX, which can be found here.

<< MaTeX`

myplot[k_: 5, n_: 10] := Plot[k*Sin[n*x], {x, -2 Pi, 2 Pi}    , PlotLabel ->     MaTeX["k=" <> ToString[k] <> ", n=" <> ToString[n],      Magnification -> 1.5]];
myplot[]

Works fine. enter image description here

But if I export the PDFs using ParallelTable,

ParallelTable[ Export[ToString[n] <> ".pdf",    myplot[RandomReal[{-3, 3}], RandomInteger[{1, 5}]]], {n, 1,    30}] // AbsoluteTiming

The labels fail to work.

enter image description here

Anyone had similar problems ? Solutions?

$\endgroup$
  • $\begingroup$ As mentioned in Details of ParallelTable: The default value is DistributedContexts:>$DistributedContexts with $DistributedContexts:=$Context, which distributes definitions of all symbols in the current context, but does not distribute definitions of symbols from packages. So DistributedContexts->All should work. $\endgroup$ – xzczd Jul 17 '18 at 17:15
  • $\begingroup$ @xzczd I looked at the Help and did DistributedContexts->All, didn't work. $\endgroup$ – Chen Stats Yu Jul 17 '18 at 17:54
  • $\begingroup$ @xzczd I think it might have something to do with LaTeX rather than MaTeX. $\endgroup$ – Chen Stats Yu Jul 17 '18 at 17:57
  • $\begingroup$ Without MaTeX: PlotLabel -> showTeX@TeXForm["k=" <> ToString[k] <> ", n=" <> ToString[n]], with showTeX discussed here mathematica.stackexchange.com/questions/178440/… $\endgroup$ – Fortsaint Jul 17 '18 at 20:17
  • $\begingroup$ You need to explicitly load packages on parallel kernels if you want to use thrm. See ParallelNeeds. I can't type well due to a wrist problem so no full answer--sorry $\endgroup$ – Szabolcs Jul 22 '18 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.