Mathematica 中具有两个数据集的 ListPlot

发布于 2024-08-28 04:12:59 字数 145 浏览 4 评论 0原文

假设我有理由保持数据集独立,是否有更干净的方法来执行以下操作?:

x = {1, 2, 3};
y = {1, 4, 9};

ListPlot[Partition[Riffle[x, y], 2]]

谢谢!

Is there a cleaner way to do the following, assuming that I have a reason to keep the data sets independent?:

x = {1, 2, 3};
y = {1, 4, 9};

ListPlot[Partition[Riffle[x, y], 2]]

Thanks!

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

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

发布评论

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

评论(3

鲜血染红嫁衣 2024-09-04 04:12:59

我不认为蒂莫的解决方案是标准的。
这里有两种方法,使用 TransposeThread,这是我经常看到的。

x = {1, 2, 3};
y = {1, 4, 9};
Transpose[{x, y}]
Thread[{x, y}]

输出:

{{1, 1}, {2, 4}, {3, 9}}
{{1, 1}, {2, 4}, {3, 9}}

这两种方法都避免显式引用数据的长度,这在我的书中是加号。

I do not think Timo's solution is standard.
Here are two methods, using Transpose or Thread, that I have often seen used.

x = {1, 2, 3};
y = {1, 4, 9};
Transpose[{x, y}]
Thread[{x, y}]

Output:

{{1, 1}, {2, 4}, {3, 9}}
{{1, 1}, {2, 4}, {3, 9}}

Both of these methods avoid explicitly referencing the length of your data which is plus in my book.

沉溺在你眼里的海 2024-09-04 04:12:59

ListPlot[转置[{x, y}]]

ListPlot[Transpose[{x, y}]]

涫野音 2024-09-04 04:12:59
ListPlot[{x,y}]

编辑:@Davorak:肯定会的。如果OP想要'y对抗x'那么

ListPlot[y]

就足够了。不管怎样,我不明白一个非常简单的问题的复杂答案。但是,我不明白很多关于SO的问题。

ListPlot[{x,y}]

EDIT: @Davorak: it certainly will. If OP wants 'y against x' then

ListPlot[y]

would suffice. Either way, I don't understand the complicated answers to a very simple question. But then, I don't understand a lot of the questions on SO.

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