Qia*_* Li 6 wolfram-mathematica
我想在模块中显示绘图(可能是递归的):
m = Module[{i, j}, i = 3; Plot[Sin[t], {t, 0, 1}]; j = 4]
Run Code Online (Sandbox Code Playgroud)
甚至
m = Module[{i, j}, i = 3; Show[Plot[Sin[t], {t, 0, 1}]]; j = 4]
Run Code Online (Sandbox Code Playgroud)
不行.为什么这样,以及如何正确绘图?
Dav*_*d Z 12
通常在Mathematica中显示绘图的唯一原因是该Plot函数返回表示绘图的图形对象,Mathematica显示您在笔记本中运行的任何内容的返回值.但是,当您使用分号跟随语句时,会阻止它返回值.
如果需要在模块中间显示某些内容,可以执行的操作是Print[Plot[...]];.该Print函数直接显示其参数的值.