plot - How do I add a box explaining which line belongs to which function?
问题描述
I want to make a plot showing the plots of two different functions. One of them is plotted using a continuous line while the other is drawn using a dashed line. I want to have a box that says something like
- - f(x)
----- g(x)
to explain which function is drawn with which line. How do I do this?
Thanks in advance
解决方案
我建议您查看有关绘图注释的文档。就您而言,该legend
功能就是您要寻找的功能。请参见以下示例:
>> a = [1 2 3 4 5];
>> b = sin(a);c = cos(a);
>> plot(a,b,'--',a,c,'-*')
>> legend('sin(a)','cos(a)')
推荐阅读
- php - texfield 中的数字
- asciidoc - 如何跨越 .adoc 文件中的多行标题?
- mysql - MariaDB、MySQL - 我的创建表语法有什么问题?
- java - 从 Java spring 获取图像以在 React 中显示
- nightwatch.js - Nightwatch.js 使用 getCookie 等客户端命令编写断言
- java - 当用户输入无效输入时,试图让我的问题循环回来
- flutter - Gridview Flutter的最后一个奇数项水平居中
- r - R闪亮的动作按钮第二次不起作用
- python - 删除多索引数据框熊猫的指定列
- google-cloud-platform - 将 memorystore redis 指标抓取到 prometheus