在 1 个图中绘制具有 2 个 y 轴的多个图
目前我有一个文本文件,第一行的数据格式如下:时间;波高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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有两组不同单位/尺度的数据,那么您可以使用
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 thatmesh
may be a better choice, giving one a 3d grid surface, orplot3
, producing distinguish lines within a 3d space.当谈论右侧的 y 尺度时,“模型中每个测量值之间的距离”是什么意思?
给定一些如下所示的数据:
其中包含 Time 列所有元素的向量称为
times
,具有波高的向量称为waveHeights
,具有距离的向量称为distances
您可以按以下方式使用plotyy()
:第一行是实际绘图,最后三行向轴添加标签。
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:
Where a vector containing all elements of the Time column is named
times
, the vector with wave height is calledwaveHeights
, and the vector with distances is calleddistances
you could useplotyy()
in this way:The first line is the actual plots and the last three add labels to the axes.