在 Mathematica 中使用单个图填充样式
我可以在如下所示的单个图中指定不同的填充颜色,还是需要“显示”多个图?假设我希望填充样式与 PlotStyle 相同。
priorMean = 50;
priorVar = 100;
llhMean = 30;
llhVar = 40;
postMean=35.71;
postVar=28.57;
Plot[
Evaluate@MapThread[
Function[{\[Mu], \[Sigma]},
PDF[NormalDistribution[\[Mu], Sqrt[\[Sigma]]], x]],
{{priorMean, llhMean, postMean}, {priorVar, llhVar, postVar}}],
{x, 0, 100}, Filling -> Axis, PlotStyle -> {Red, Green, Blue}]
Could I specify different filling colors for within a single plot like the bellow or would I need to "Show" several Plots ? Let`s say I would like the filling style to be the same as the PlotStyle.
priorMean = 50;
priorVar = 100;
llhMean = 30;
llhVar = 40;
postMean=35.71;
postVar=28.57;
Plot[
Evaluate@MapThread[
Function[{\[Mu], \[Sigma]},
PDF[NormalDistribution[\[Mu], Sqrt[\[Sigma]]], x]],
{{priorMean, llhMean, postMean}, {priorVar, llhVar, postVar}}],
{x, 0, 100}, Filling -> Axis, PlotStyle -> {Red, Green, Blue}]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用
FillingStyle
来填写。我认为您陷入了FillingStyle
的语法,它与FillingStyle
不同。对于PlotStyle
,尽管您希望如此。您必须为每条曲线指定一种颜色FillingStyle -> {1->颜色1, 2 -> color2}
等。这是一个示例:You'll need to use
FillingStyle
to fill in. I think you got stuck in the syntax forFillingStyle
, which is not the same as that forPlotStyle
, although you'd expect it to be. You'll have to assign a color for each curve asFillingStyle -> {1 -> color1, 2 -> color2}
, etc. Here's an example:我建议对 Plot 的定义进行扩展。 我之前已经这样做过。
完成此操作后,您可以使用
FillingStyle -> “匹配”
自动设置填充样式以匹配主要样式。I propose making an extension to the definition of
Plot
. I have done this before.With this in place, you can use
FillingStyle -> "Match"
to auto-style the fills to match the main styles.你可以做类似
You could do something like
得到的结果是:
在帮助中的 FillingStyle、Scope、Filling Style 下找到。
或者:
This gets a result:
Found in the help under FillingStyle, Scope, Filling Style.
And alternatively: