在 1 个图中绘制具有 2 个 y 轴的多个图

发布于 2024-08-26 08:32:52 字数 402 浏览 4 评论 0原文

目前我有一个文本文件,第一行的数据格式如下:时间;波高1;波高2;.......我有列直到波高19,行总数为4000行。

第一列中的数据是第二列中的时间。从第二列开始,是以米为单位的波高高程。

我想绘制以下内容:

x 轴上是时间。 左侧是波高,单位为米 右侧是模型中每个测量值之间的距离。

图中有 4 个图,每个图代表与右侧 y asix 相关的定义距离处的波峰 1、波高 2 等。

你会如何在 matlab 中编写这个代码?

我是初学者,如果可以的话,请在您的答案中提供更多解释,这将非常有用!我试图发布一张图片来澄清问题,但 stackoverflow 不允许我这样做。如果不清楚,请与我联系,我可以通过电子邮件将我针对此问题的图表发送给您。

谢谢你!!!!!!!!!!

Currently I have a a text file with data at the first row is formatted as follow: time;wave height 1;wave height 2;....... I have column until wave height 19 and rows total 4000 rows.

Data in the first column is time in second. From 2nd column onwards, it is wave height elevation which is in meter.

I would like to plot the follow:

on the x axis is time.
the left hand side is wave height in m
and on the right hand side is the distance between each measurment in a model.

inside the graph there are 4 plots, each plot is repersent waveight 1, wave height 2etc at a defined distance related to the right hand side y asix.

How would you code this in matlab?

I am a begineer, please if you could, it will be very useful to give a bit more explain in your answer! I was trying to post an picture up to clear things up but stackoverflow don't allow me to do that. If it is un clear please contact me and i can email you the graph i mean for this question.

Thank you!!!!!!!!!!

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

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

发布评论

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

评论(2

泪冰清 2024-09-02 08:32:52

如果您有两组不同单位/尺度的数据,那么您可以使用plotyy。但是,在您此处描述的情况下,似乎 mesh 可能是更好的选择,它提供 3d 网格表面或 plot3,在 3d 空间内生成区分线。

If you are have 2 sets of data of different units/scales, then you may use plotyy. However, in the case you described here, it seems that mesh may be a better choice, giving one a 3d grid surface, or plot3, producing distinguish lines within a 3d space.

寂寞美少年 2024-09-02 08:32:52

当谈论右侧的 y 尺度时,“模型中每个测量值之间的距离”是什么意思?

给定一些如下所示的数据:

#Time               #Wave Height         #Distance Between Measurements(?)
 0000                1.00                 1.00
 0001                1.13                 0.81
 0003                1.58                 0.73
 ...                 ...                  ...
 4000                0.23                 1.19

其中包含 Time 列所有元素的向量称为 times,具有波高的向量称为 waveHeights,具有距离的向量称为 distances 您可以按以下方式使用 plotyy()

[AX,H1,H2] = plotyy(times,waveHeights,times,distances,'plot');

set(get(AX(1),'Ylabel'),'String','Wave Height') 
set(get(AX(2),'Ylabel'),'String','Distance Between Measurements')
xlabel('Time (s)')

第一行是实际绘图,最后三行向轴添加标签。

What do you mean the "distance between each measurment in a model" when talking about the y-scale on the right?

Given some data that looks like this:

#Time               #Wave Height         #Distance Between Measurements(?)
 0000                1.00                 1.00
 0001                1.13                 0.81
 0003                1.58                 0.73
 ...                 ...                  ...
 4000                0.23                 1.19

Where a vector containing all elements of the Time column is named times, the vector with wave height is called waveHeights, and the vector with distances is called distances you could use plotyy() in this way:

[AX,H1,H2] = plotyy(times,waveHeights,times,distances,'plot');

set(get(AX(1),'Ylabel'),'String','Wave Height') 
set(get(AX(2),'Ylabel'),'String','Distance Between Measurements')
xlabel('Time (s)')

The first line is the actual plots and the last three add labels to the axes.

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