在 Mathematica 中组合图未给出预期结果
我正在尝试组合在 Plot[]
上绘制的 3 个函数和在 ParametricPlot[]
上绘制的 1 个函数。我的方程如下:
plota = Plot[{-2 x, -2 Sqrt[x], -2 x^(3/5)}, {x, 0, 1}, PlotLegend -> {"-2 x", "-2 \!\(\*SqrtBox[\(x\)]\)", "-2 \!\(\*SuperscriptBox[\(x\), \(3/5\)]\)"}]
plotb = ParametricPlot[{2.4056 (u - Sin[u]), 2.4056 (Cos[u] - 1)}, {u,0, 1.40138}, PlotLegend -> {"Problem 3"}]
Show[plota, plotb]
这是它给出的图像:
I'm trying to combine 3 functions graphed on a Plot[]
and 1 function graphed on a ParametricPlot[]
. My equations are as follows:
plota = Plot[{-2 x, -2 Sqrt[x], -2 x^(3/5)}, {x, 0, 1}, PlotLegend -> {"-2 x", "-2 \!\(\*SqrtBox[\(x\)]\)", "-2 \!\(\*SuperscriptBox[\(x\), \(3/5\)]\)"}]
plotb = ParametricPlot[{2.4056 (u - Sin[u]), 2.4056 (Cos[u] - 1)}, {u,0, 1.40138}, PlotLegend -> {"Problem 3"}]
Show[plota, plotb]
This is the image it gives:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 yoda 所说,
PlotLegends
很糟糕。但是,如果您不介意手动设置绘图样式并稍后重复它们,ShowLegend
可以提供帮助。现在
将为您提供以下内容:
您还可以编写一些简单的函数来减少一些麻烦,如果你经常处理这个问题。
As yoda said,
PlotLegends
is terrible. However, if you don't mind setting the plot styles manually and repeating them lateron,ShowLegend
can help.And now
which will give you this:
You can also write some simple functions to make this a little less cumbersome, if you deal with this problem often.
好吧,错误的根本原因是
PlotLegends
包,这是一个可怕的、有缺陷的包。删除它,Show
可以正确组合它们:您可以看到 Simon 的解决方案 此处获取在不使用标签的情况下标记不同曲线的想法
PlotLegends
。 James 的这个答案也说明了为什么PlotLegends
具有它所拥有的声誉...您仍然可以使用
PlotLegends
包来挽救一些东西。下面是一个使用ShowLegends
的示例,您可以根据自己的喜好进行修改Well, the root cause of the error is the
PlotLegends
package, which is a terrible, buggy package. Removing that,Show
combines them correctly:You can see Simon's solution here for ideas to label your different curves without using
PlotLegends
. This answer by James also demonstrates whyPlotLegends
has the reputation it has...You can still salvage something with the
PlotLegends
package. Here's an example usingShowLegends
that you can modify to your tastes正如其他答案所指出的,罪魁祸首是 PlotLegend。因此,有时能够滚动自己的图例很有用:
As the other answers pointed out, the culprit is
PlotLegend
. So, sometimes is useful to be able to roll your own plot legends: