简体   繁体   English

matlab散点图时间序列

[英]matlab scatter plot time series

I would like to look at two dimensional data in a time-series - the first idea I had was to use a scatter plot, where you can easily explore timepoint-to-timepoint.我想查看时间序列中的二维数据 - 我的第一个想法是使用散点图,您可以在其中轻松探索时间点到时间点。 Is there a function I could use for this?有我可以使用的功能吗? I looked at scatter3 but it can only plot perfectly-cubic data, not as below:我查看了 scatter3 但它只能绘制完美的三次数据,而不是如下:

eg例如

data=rand(5,5,3);
scatter3(data(1,:,:),data(:,1,:),data(:,:,1)) %throws an error

thanks谢谢

edit: Originally I had something like > this < in mind编辑:最初我有这样的事情 > 这个< 记住

scatter3 seems to be for 3D plots, but you say your data is 2D. scatter3 似乎用于 3D 图,但您说您的数据是 2D。

For a simple time-series graph you could presumably even just use plot:对于简单的时间序列图,您甚至可以只使用 plot:

figure
nPoints = 25;
dataX = 1:nPoints;
dataY = rand(1,nPoints);
plot(dataX,dataY, 'o-')

However, the example you give in your link looks like something else, so it seems like scatter (rather than scatter3) might be what you're after.但是,您在链接中给出的示例看起来像其他内容,因此似乎 scatter(而不是 scatter3)可能是您所追求的。 Maybe something like this?也许是这样的?

figure
nPoints = 25;
dataX = 1:nPoints;
dataY = rand(1,nPoints);
dataArea = rand(1,nPoints)*100;
dataColours = rand(nPoints,3);

scatter(dataX,dataY,dataArea,dataColours)

EDIT: I think I understand better what you mean, sorry I didn't see the buttons at the bottom of the link, but correct me if I'm wrong.编辑:我想我更明白你的意思,抱歉我没有看到链接底部的按钮,但如果我错了,请纠正我。 So you have a set of XY coordinates for multiple objects at different points in time, and ideally you want to plot how the XY coordinates of each object (in 2 dimensions) change over time (in 3 dimensions).因此,您有一组不同时间点的多个对象的 XY 坐标,理想情况下,您希望绘制每个对象的 XY 坐标(二维)随时间(3 维)的变化情况。 Your initial approach in using scatter3 was to try and make a simple 3d graph, but maybe ideally you want a 2d graph that can be either animated or interactive, to change the time point displayed at any given time?您最初使用 scatter3 的方法是尝试制作一个简单的 3d 图形,但理想情况下,您可能想要一个可以动画或交互式的 2d 图形,以更改在任何给定时间显示的时间点?

Going back to your original question, I think the issue with your attempt to use scatter3 (or plot3 might be useful too) is I'm not sure what your dummy data would represent.回到您最初的问题,我认为您尝试使用 scatter3 (或 plot3 也可能有用)的问题是我不确定您的虚拟数据将代表什么。 You created data as a 5x5x3 matrix, and I assume that might represent 25 data points, at 3 different time intervals?您将数据创建为 5x5x3 矩阵,我假设这可能代表 3 个不同时间间隔的 25 个数据点? However, which data would represent the X and which the Y coordinates?但是,哪些数据代表 X 坐标,哪些代表 Y 坐标? It would work with something like the following, where each variable represents the X/Y/Z coordinates of 6 objects (columns) at 5 different time points (rows)它将与以下内容一起使用,其中每个变量代表 6 个对象(列)在 5 个不同时间点(行)的 X/Y/Z 坐标

myX = rand(5,6,1);
myY = rand(5,6,1);
% I'm making each time point increase linearly.
myZ = repmat((1:size(myX,1))', 1, size(myX,2));
plot3(myX, myY, myZ, 'o-')
grid on
% Note I find the default dimensions it treats as X, Y and Z unintuitive (e.g. the Z dimension is the vertical dimension), but one could swap the input arguments around to overcome this.

However, especially if you have a lot of points, I'm not sure how clear a graph like this will be, especially compared to the example in your link.但是,特别是如果您有很多要点,我不确定这样的图表有多清晰,尤其是与您链接中的示例相比。

Instead it seems like you ideally want only the XY coordinates of all objects to be plotted for only one time point at once, and a way to cycle through each time point sequentially.相反,理想情况下,您似乎只希望一次只绘制一个时间点的所有对象的 XY 坐标,并按顺序循环遍历每个时间点。 This seems trickier, and maybe someone else will be able to answer better than I have.这似乎更棘手,也许其他人能够比我回答得更好。 A couple more questions though that might be useful:还有几个问题可能有用:

  • How much do you care about the smoothness of the transition.你有多关心过渡的平滑度。 In the example link the circles move smoothly from one position to another, rather than just jumping/teleporting between points.在示例链接中,圆圈从一个位置平滑地移动到另一个位置,而不仅仅是在点之间跳跃/传送。
  • Ideally do you want a function that would produce an 'animation', cycling through all the time points from begining to end, or a way of manually specifying/changing which time point is being displayed.理想情况下,您想要一个可以产生“动画”的函数,从开始到结束循环所有时间点,还是手动指定/更改正在显示的时间点的方法。 If the former, maybe this function would be useful (though I've tried it myself yet) https://uk.mathworks.com/matlabcentral/fileexchange/42305-multicomet如果是前者,也许这个功能会很有用(虽然我自己已经尝试过了) https://uk.mathworks.com/matlabcentral/fileexchange/42305-multicomet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM