最大同时显示和保存绘图
Display and save plot simultaneously in maxima
目前,我可以在maxima中显示如下图:
f(x) := sin(x)$
g(x) := cos(x)$
plot2d([f(x), g(x)], [x,-5,5],[legend,"sin(x)","cos(x)"],
[xlabel,"x"],[ylabel,"y"],
[gnuplot_preamble,"set key box spacing 1.3 top right"])$
并使用以下命令保存绘图:
plot2d([f(x), g(x)], [x,-5,5],[legend,"sin(x)","cos(x)"],
[xlabel,"x"],[ylabel,"y"],
[pdf_file,"./trigplot.pdf"],
[gnuplot_preamble,"set key box spacing 1.3 top right"]
)$
如何在maxima中同时显示和保存绘图?
p2
采用文件名和与 plot2d
.
相同的参数
p2(file, [L])::=buildq([file, L],
(plot2d(splice(L)),
plot2d(splice(L), ['pdf_file, file])))$
f(x) := sin(x)$
g(x) := cos(x)$
p2("trigplot.pdf",
[f(x), g(x)], [x,-5,5],
[legend,"sin(x)","cos(x)"],
[xlabel,"x"],[ylabel,"y"],
[gnuplot_preamble,"set key box spacing 1.3 top right"]);
是a macro。首先它替换 file
和 L
。 splice(L)` 被转换为参数列表。替换后,结果表达式在调用者的上下文中进行计算。
您可以使用macroexpand
查看替换后的表达式。
(%i1) a: 42 $
(%i2) macroexpand(p2(file, a, b));
(%o2) (plot2d(a, b), plot2d(a, b, ['pdf_file, file]))
目前,我可以在maxima中显示如下图:
f(x) := sin(x)$
g(x) := cos(x)$
plot2d([f(x), g(x)], [x,-5,5],[legend,"sin(x)","cos(x)"],
[xlabel,"x"],[ylabel,"y"],
[gnuplot_preamble,"set key box spacing 1.3 top right"])$
并使用以下命令保存绘图:
plot2d([f(x), g(x)], [x,-5,5],[legend,"sin(x)","cos(x)"],
[xlabel,"x"],[ylabel,"y"],
[pdf_file,"./trigplot.pdf"],
[gnuplot_preamble,"set key box spacing 1.3 top right"]
)$
如何在maxima中同时显示和保存绘图?
p2
采用文件名和与 plot2d
.
p2(file, [L])::=buildq([file, L],
(plot2d(splice(L)),
plot2d(splice(L), ['pdf_file, file])))$
f(x) := sin(x)$
g(x) := cos(x)$
p2("trigplot.pdf",
[f(x), g(x)], [x,-5,5],
[legend,"sin(x)","cos(x)"],
[xlabel,"x"],[ylabel,"y"],
[gnuplot_preamble,"set key box spacing 1.3 top right"]);
是a macro。首先它替换 file
和 L
。 splice(L)` 被转换为参数列表。替换后,结果表达式在调用者的上下文中进行计算。
您可以使用macroexpand
查看替换后的表达式。
(%i1) a: 42 $
(%i2) macroexpand(p2(file, a, b));
(%o2) (plot2d(a, b), plot2d(a, b, ['pdf_file, file]))