问题描述
如何绘制下面给出的图形?
How to plot a figure like the one given below?
在此处,图例(绿色/蓝色)在每条曲线上均带有一些值(0.10至0.40).有任何可行的解决方案或提示吗?
Here the legend (green/blue) is plotted with some values (0.10 to 0.40) on each curve. Is there any possible solution or hints to do this?
图参考:
推荐答案
使用 clabel (轮廓标签),尽管这要求您使用轮廓命令.
Plotting data labels within lines is possible with clabel (contour labels), although this requires that you to plot your data with the contour command.
尽管不能将其绘制为等高线图,则应该能够将其数据转换为等高线矩阵格式,请参见轮廓算法.这是一个简单的2行向量,用于定义数据点,您应该能够将此矩阵输入clabel函数中,以内联方式打印数据标签.
Although if you can't plot it as a contour plot then you should be able to convert your plot data to a contour matrix format, see the matrix definition at the bottom of the help page on the contour algorithm. This is a simple 2 row vector defining your data points, you should be able to feed this matrix into the clabel function to print the data labels inline.
对于下面的示例-我使用plot命令绘制了3条线,并将线控点保存在数组h中.然后,我根据绘制的数据创建了一个轮廓矩阵,例如,如果红线有50个数据点,那么
For the example below - I plotted the 3 lines using the plot command, saving the line handles in the array h. I then created a contour matrix from the plotted data, so for example if the red line had 50 data points then
C(1,1)=0.44; % data value to plot on the line
C(2,1)=50; % number of data points
C(1,2:51)=line1x; % x data points for the red line
C(2,2:51)=line1y; % y data points for the red line
我手动进行了测试,但是我敢肯定,如果需要,您可以编写一个简单的函数从您的数据自动创建此矩阵.无论如何,重复将其他线数据添加到轮廓矩阵,然后使用轮廓标签命令
I did it manually to test the idea but I'm sure you could write a simple function to create this matrix automatically from your data if required. Anyway repeat adding the other line data to the contour matrix then use the contour label command
clabel(C,h)
哪个给我这个情节
这篇关于Matlab图形绘图-带标签的图例和曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!