如何在 MATLAB 中绘制 3D 绘图?
我有三个参数x
、y
和t
。但问题是我的文件结构。
我的文件命名为:
e_x_y.txt
t_x_y.txt
其中 e_x_y.txt
对于 x
和 y
以及 t_x_y.txt
的特定值有错误code> 有相应的时间值。
我需要在 x vs y vs t
图表上绘制 e_x_y.txt
中的值。
最好的方法是什么?
我知道 x 和 y 值是什么,所以我不必从文件名中扣除它们。
为了让事情更清楚,
假设我的文件是:
e_4_5.txt
45
54
t_4_5.txt
2.0
6.0
e_7_8.txt
32
98
121
t_7_8.txt
2
9
1.0
我想绘制以下几点:
(4,5,2.0) = 45
(4,5,6.0) = 54
(7,8,2.0) = 32
(7,8,9.0) = 98
(7,8,1.0) = 121
I have three parameters x
,y
and t
. But the problem is my file structure.
My files are named as:
e_x_y.txt
t_x_y.txt
where e_x_y.txt
has the error for particular values of x
and y
and t_x_y.txt
has corresponding time values.
I need to plot the values in e_x_y.txt
on a x vs y vs t
graph.
What is the best way to do that?
I know what x and y values are, so I don't have to deduct them from the file names.
To make things more clear,
suppose my files are:
e_4_5.txt
45
54
t_4_5.txt
2.0
6.0
e_7_8.txt
32
98
121
t_7_8.txt
2
9
1.0
I want to plot the following points:
(4,5,2.0) = 45
(4,5,6.0) = 54
(7,8,2.0) = 32
(7,8,9.0) = 98
(7,8,1.0) = 121
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试绘制的绘图类型可能很难很好地可视化。我可以给你两个建议:一个是你想要的,一个是你可能应该做的……
绘制 4 维数据:
为了做到这一点,你必须绘制一个一系列
x,y,t
点并以某种方式表示每个点的误差值e
。您可以通过更改点的颜色或大小来做到这一点。在此示例中,我将在每个点处绘制一个球体,其直径根据误差而变化(直径 1 等于最大预期误差)。颜色代表时间。我将使用您添加到问题中的示例数据(格式为 5×4 矩阵,其中的列包含x
、y、
t
和e
数据):如下所示:
问题:虽然剧情看起来很有趣,但并不是很直观。此外,以这种方式绘制大量点会变得混乱,并且很难清楚地看到它们。
更直观的 3-D 绘图:
最好制作数据的 3-D 绘图,因为它可能更容易解释。这里,x 轴代表迭代次数,y 轴代表每个单独的网络:
这会产生更清晰的图:
The type of plot you are trying to make may be difficult to visualize well. I can give you two suggestions: one is what you want, and one is what you should probably do instead...
Plotting 4-D data:
In order to do this, you will have to plot a series of
x,y,t
points and somehow represent the error valuee
at each point. You could do this by changing the color or size of the point. In this example, I'll plot a sphere at each point with a diameter that varies based on the error (a diameter of 1 equates to the maximum expected error). The color represents the time. I'll be using the sample data you added to the question (formatted as a 5-by-4 matrix with the columns containing thex
,y
,t
, ande
data):And here's what it would look like:
The problem: Although the plot looks kind of interesting, it's not very intuitive. Also, plotting lots of points in this way will get cluttered and it will be hard to see them all well.
More intuitive 3-D plot:
It may be better to instead make a 3-D plot of the data, since it may be easier to interpret. Here, the x-axis represents the iteration number and the y-axis represents each individual network:
This produces a much clearer plot:
尽管我不相信这是可视化数据的最佳方法,但这里有一个简单的方法可以按照您的要求进行操作。您可以在简单的散点图中绘制 3D 点,并将大小或颜色映射到第四维误差值。类似于:
Even though I am not convinced this the best way to visualize the data, here's a simple way to do it as you asked. You can plot the 3D points in a simple scatter plot, and map the size OR the color to the values of the fourth dimension
error
. Something like: