在 Mathematica 中,我们如何将循环生成的许多图合并为一个图?
我想可视化 x^n 形式的函数,使得 n=1,2,...,10。 我希望这些 n 值由循环生成,然后将函数绘制为 绘制 [{x^n},{x,0,100}] 并将绘图存储在数组中。然后我希望所有这些数组都显示在单个图中。我尝试使用 Show 函数来执行此操作,但没有太多有用的结果。另外,如果您还可以告诉我如何为所有组合图设置不同的颜色并显示图例。
I want to visualize a function of the form x^n such that n=1,2,...,10.
I want these values of n to be generated by a loop and then plot the function as
Plot[{x^n},{x,0,100}] and store the plot in an array. Then I want all of these arrays to be displayed into single plot. I tried to do this using Show function but with not much useful results. Also if you can also tell me how to set different colour for all the combined plots and also display a Legend.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能再澄清一下你想要什么吗?具体来说,为什么 Show 对你不起作用?
组合绘图是 Show 的用途:
(我指定了 PlotRange 这里,因为每个图都有不同的自动选择的绘图范围。)
Plot 也可以直接一次绘制多个函数:
(在第一个示例中,我使用了 ColorData 模仿与第二个示例中自动使用的完全相同的颜色...但您可以使用任何您想要的颜色,例如
Hue[RandomReal[]]
。)Can you clarify a bit more what you want? Specifically, why didn't Show work for you?
Combining plots is what Show is intended for:
(I specified a PlotRange here, since each of these plots has a different automatically chosen plot range.)
Plot can also directly plot multiple functions at once:
(In the first example I used ColorData to mimic the exact same colors as are automatically used in the second example... But you can use any colors you want, such as
Hue[RandomReal[]]
.)