在 Mathematica 中绘制两条折线时 PlotMarkers 消失?

发布于 2024-12-21 15:11:50 字数 1148 浏览 1 评论 0原文

不确定这是 MMA 错误还是我做错了什么。 考虑以下函数:

plotTrace[points_] :=
 ListPlot[points,
  Joined -> True,
  PlotMarkers -> Table[i, {i, Length@points}]]

现在考虑向其传递由 RandomReal 生成的值。即,考虑

RandomReal[1, {nTraces, nPointsPerTrace, 2(*constant = nDimensions*)}]. 

如果 nTraces 为 1,则为我尝试过的 nPointsPerTrace 的所有值显示 PlotMarkers:

Manipulate[
 plotTrace[RandomReal[1, {1, nPointsPerTrace, 2}]], 
 {nPointsPerTrace, 1, 20, 1}]

当 nTraces == 时绘制随机点1

如果 nTraces 为 3 或更大,则为我尝试过的 nPointsPerTrace 的所有值显示绘图标记

Manipulate[plotTrace[RandomReal[1, {nTraces, nPointsPerTrace, 2}]],
 {nTraces, 3, 20, 1}, {nPointsPerTrace, 1, 20, 1}]

当 nTraces >= 3 时绘制随机点

但是如果 nTraces 恰好为 2,则无论值是多少,我都看不到绘图标记nPointsPerTrace:

Manipulate[plotTrace[RandomReal[1, {2, nPointsPerTrace, 2}]],
 {nPointsPerTrace, 1, 20, 1}]

当 nTraces == 2 时绘制随机点

提示、线索、建议不胜感激!

Not sure if this is a MMA bug or me doing something wrong.
Consider the following function:

plotTrace[points_] :=
 ListPlot[points,
  Joined -> True,
  PlotMarkers -> Table[i, {i, Length@points}]]

now consider passing it values generated by RandomReal. Namely, consider

RandomReal[1, {nTraces, nPointsPerTrace, 2(*constant = nDimensions*)}]. 

If nTraces is 1, then PlotMarkers are displayed for all values of nPointsPerTrace that I tried:

Manipulate[
 plotTrace[RandomReal[1, {1, nPointsPerTrace, 2}]], 
 {nPointsPerTrace, 1, 20, 1}]

plotting random points when nTraces == 1

If nTraces is 3 or greater, then plot markers are displayed for all values of nPointsPerTrace that I tried

Manipulate[plotTrace[RandomReal[1, {nTraces, nPointsPerTrace, 2}]],
 {nTraces, 3, 20, 1}, {nPointsPerTrace, 1, 20, 1}]

plotting random points when nTraces >= 3

But if nTraces is exactly 2, I don't see plot markers, no matter the value of nPointsPerTrace:

Manipulate[plotTrace[RandomReal[1, {2, nPointsPerTrace, 2}]],
 {nPointsPerTrace, 1, 20, 1}]

plotting random points when nTraces == 2

Hints, clues, advice would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨曦÷微暖 2024-12-28 15:11:50

它正在处理 PlotMarkers -> {1,2} 作为标记和大小,而不是作为两个标记:

In[137]:= ListPlot[{{1, 2, 3}, {4, 5, 6}}, PlotMarkers -> {1, 2}] // InputForm

Out[137]//InputForm=
Graphics[GraphicsComplex[{{1., 1.}, {2., 2.}, {3., 3.}, {1., 4.}, {2., 5.}, {3., 6.}, 
  {1., 1.}, {2., 2.}, {3., 3.}, {1., 4.}, {2., 5.}, {3., 6.}}, 
  {{{Hue[0.67, 0.6, 0.6], Inset[Style[1, FontSize -> 2], 7], 
     Inset[Style[1, FontSize -> 2], 8], Inset[Style[1, FontSize -> 2], 9]}, 
    {Hue[0.9060679774997897, 0.6, 0.6], Inset[Style[1, FontSize -> 2], 10], 
     Inset[Style[1, FontSize -> 2], 11], Inset[Style[1, FontSize -> 2], 12]}, {}}}], 
 {AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesOrigin -> {0, 0}, 
  PlotRange -> {{0, 3.}, {0, 6.}}, PlotRangeClipping -> True, 
  PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}]

It's treating PlotMarkers -> {1,2} as a marker and size, instead of as two markers:

In[137]:= ListPlot[{{1, 2, 3}, {4, 5, 6}}, PlotMarkers -> {1, 2}] // InputForm

Out[137]//InputForm=
Graphics[GraphicsComplex[{{1., 1.}, {2., 2.}, {3., 3.}, {1., 4.}, {2., 5.}, {3., 6.}, 
  {1., 1.}, {2., 2.}, {3., 3.}, {1., 4.}, {2., 5.}, {3., 6.}}, 
  {{{Hue[0.67, 0.6, 0.6], Inset[Style[1, FontSize -> 2], 7], 
     Inset[Style[1, FontSize -> 2], 8], Inset[Style[1, FontSize -> 2], 9]}, 
    {Hue[0.9060679774997897, 0.6, 0.6], Inset[Style[1, FontSize -> 2], 10], 
     Inset[Style[1, FontSize -> 2], 11], Inset[Style[1, FontSize -> 2], 12]}, {}}}], 
 {AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesOrigin -> {0, 0}, 
  PlotRange -> {{0, 3.}, {0, 6.}}, PlotRangeClipping -> True, 
  PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}]
梓梦 2024-12-28 15:11:50

当您为 PlotMarkers 尝试不同的操作时,事情会变得更加奇怪。下面不显示绘图标记,如上面的示例所示。

pts = RandomReal[1, {2, 10, 2}];
(* No markers *)
ListPlot[pts,
 Joined -> True,
 PlotMarkers -> {1, 2}
 ]

Mathematicagraphics

但是,当您将 2 更改为 b 时,它确实如此:

pts = RandomReal[1, {2, 10, 2}];
(* Has markers *)
ListPlot[pts,
 Joined -> True,
 PlotMarkers -> {1, b}
 ]

Mathematicagraphics

如果您尝试将 1 更改为某些内容,则不会工作:

pts = RandomReal[1, {2, 10, 2}];
(* No markers *)
ListPlot[pts,
 Joined -> True,
 PlotMarkers -> {a, 2}
 ]

Mathematicagraphics

这确实听起来像一个错误,但我不确定这是否与版本相关或某些不明显的行为。

Things get even stranger when you try different things for PlotMarkers. The following does not display the plot markers, as in your examples above.

pts = RandomReal[1, {2, 10, 2}];
(* No markers *)
ListPlot[pts,
 Joined -> True,
 PlotMarkers -> {1, 2}
 ]

Mathematica graphics

However, when you change the 2 to b, it does:

pts = RandomReal[1, {2, 10, 2}];
(* Has markers *)
ListPlot[pts,
 Joined -> True,
 PlotMarkers -> {1, b}
 ]

Mathematica graphics

If you try to change the 1 to something, it doesn't work:

pts = RandomReal[1, {2, 10, 2}];
(* No markers *)
ListPlot[pts,
 Joined -> True,
 PlotMarkers -> {a, 2}
 ]

Mathematica graphics

It does indeed sound like a bug, but I'm not sure if this is version dependent or some behavior that's not obvious.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文