Mathematica 中具有两个数据集的 ListPlot
假设我有理由保持数据集独立,是否有更干净的方法来执行以下操作?:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不认为蒂莫的解决方案是标准的。
这里有两种方法,使用
Transpose
或Thread
,这是我经常看到的。输出:
这两种方法都避免显式引用数据的长度,这在我的书中是加号。
I do not think Timo's solution is standard.
Here are two methods, using
Transpose
orThread
, that I have often seen used.Output:
Both of these methods avoid explicitly referencing the length of your data which is plus in my book.
ListPlot[转置[{x, y}]]
ListPlot[Transpose[{x, y}]]
编辑:@Davorak:肯定会的。如果OP想要'y对抗x'那么
就足够了。不管怎样,我不明白一个非常简单的问题的复杂答案。但是,我不明白很多关于SO的问题。
EDIT: @Davorak: it certainly will. If OP wants 'y against x' then
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.