title author date CreateTime categories
matlab 画图
lindexi
2019-08-31 16:55:59 +0800
2018-2-13 17:23:3 +0800

本文讲如何使用 matlab 画图。
本文包括:折线图的 x轴和y轴、标题、图例
柱状图填充图案

折线图

接下来讲的matlab如何设置图形的图例和x轴的距离

折线图的图例需要知道的是 Legend ,使用他可以进行设置

  1. legend(...,'Location',LOC) adds a legend in the specified
  2. location, LOC, with respect to the axes. LOC may be either a
  3. 1x4 position vector or one of the following strings:
  4. 'North' inside plot box near top
  5. 'South' inside bottom
  6. 'East' inside right
  7. 'West' inside left
  8. 'NorthEast' inside top right (default for 2-D plots)
  9. 'NorthWest' inside top left
  10. 'SouthEast' inside bottom right
  11. 'SouthWest' inside bottom left
  12. 'NorthOutside' outside plot box near top
  13. 'SouthOutside' outside bottom
  14. 'EastOutside' outside right
  15. 'WestOutside' outside left
  16. 'NorthEastOutside' outside top right (default for 3-D plots)
  17. 'NorthWestOutside' outside top left
  18. 'SouthEastOutside' outside bottom right
  19. 'SouthWestOutside' outside bottom left
  20. 'Best' least conflict with data in plot
  21. 'BestOutside' least unused space outside plot

如何设置x轴大小?

可以通过set(gca,'xtick',1:1:100);代码设置从1开始,结束100,解释一下

set(gca,'xtick',开始:两个点之间:结束);

直方图

如何画柱状图,如何在柱状图使用不同的图案填充?

matlab 柱状图填充图案可以使用 applyhatch 画图,下面将告诉大家如何做

第一步是复制文件applyhatch.m到自己电脑。关于applyhatch.m到哪里下,请自己百度,如果寻找不到,可以联系我lindexi_gd@163.com

才不告诉在这里

第二步是把文件拷贝到工作台,工作台是什么,就是软件打开的文件夹路径,这个路径如下图

可以自己修改,只要把上面的文件放在这个文件夹就可以了。

使用方式是applyhatch(gcf,'\.x.');

其中第二个参数就是使用不同的图案,可以使用添加'/', '\', '|', '-', '+', 'x', '.'几个字符

例子:

  1. close all
  2. clear all
  3. clc
  4. % The computer journal paper
  5. % Jigang Wu etc.
  6. % copyright: lonchen@mail.ustc.edu.cn
  7.  
  8. % data = [31,32,35;72,73,75;113,114,117;144,146,147;171,173,174;213,215,220];
  9. data =[16,17,18;33,34,37;51,54,55;71,74,74;86,91,91;105,113,113];
  10. bar(data,1);
  11. axis([0 7 0.0 150]);
  12. legend('DPA','TSRP','GRP',0);
  13. grid on;
  14. set(gca,'XTickLabel',{'100','200','300','400','500','600'});
  15.  
  16. xlabel('The number of internal nodes');
  17. ylabel('The number of replica that created');
  18. set(gcf,'Color','w'); % 设置背景颜色为白色,否则坐标轴出现区域的颜色为灰色
  19. applyhatch(gcf,'\.x.');

对于不同组合的直方图,使用 data=[数据1.1,数据1.2,数据1.3;数据2.1,数据2.2……]

然后画出来,使用bar(data,1); 第二个参数是宽度,自己尝试修改第二个值跑一下。

可以使用图例,matlab的图例使用的legend('DPA','TSRP','GRP',0); 有多少个数据就添加对应图例。

试试下面代码:

  1. y=[559006 ,2269384,783762;508559 ,2140905,696001;506491,2007763,735464]
  2. bar(y,0.6)
  3.  
  4. legend('n','N','l')
  5. grid on;
  6. set(gca,'XTickLabel',{'第一次','第二次','第三次'})
  7.  
  8. xlabel('匹配次数')
  9.  
  10. ylabel('结果数')
  11.  
  12. set (gcf,'Position',[500,500,500,500], 'color','w')
  13.  
  14. applyhatch(gcf,'\.x./');
  15.  
  16. set(gcf,'Color','w');

如果过程遇到问题,可以联系我 lindexi_gd@163.com

感谢陈龙师兄的帮助。

Matlab绘图高级部分

2019-8-31-matlab-画图的更多相关文章

  1. Matlab画图,坐标轴范围设置和间隔设置

    在Matlab画图的时候,系统默认的坐标轴范围以及间隔有时候并不是很合适,如何根据自己的要求来显示呢,Set语句就可以帮忙咯!! 1. set(gca,'xtick',0:100:2500)      ...

  2. Matlab画图-非常具体,非常全面

    Matlab画图 强大的画图功能是Matlab的特点之中的一个,Matlab提供了一系列的画图函数,用户不须要过多的考虑画图的细节,仅仅须要给出一些基本參数就能得到所需图形,这类函数称为高层画图函数. ...

  3. 设置 matlab 画图格式

    1:设置 matlab 画图格式 clear;clc; % load("array.mat"); % Bestallarray=array; % rllofcircle(Besta ...

  4. 如何解决 Matlab 画图时中文显示乱码的问题?

    使用的是win10系统,从前几个月某一天,我的matlab的figure里的中文都变成了口口.很是郁闷,还以为是动到了什么配置引起的. 前几天更新了matlab 2018b,发现还有这个问题.就觉得不 ...

  5. matlab 画图进阶

    matlab 画图进阶 applications of matlab in engineering 图表类型的选择 first:advanced 2d plots special plots logl ...

  6. matlab 画图技巧

    基本画图工具:matlab 画图中线型及颜色设置 matlab中坐标轴设置技巧 **Matlab中的坐标轴设置技巧**    axisoff;      %去掉坐标轴  axistight;      ...

  7. agentzh 的 Nginx 教程(版本 2019.07.31)

    agentzh 的 Nginx 教程(版本 2019.07.31) agentzh 的 Nginx 教程(版本 2019.07.31) https://openresty.org/download/a ...

  8. 20140513 matlab画图

    1.matlab画图 x1=[1.00E-06,2.00E-06,4.00E-06,9.00E-06,2.00E-05,4.00E-05,8.00E-05,2.00E-04,4.00E-04,7.00 ...

  9. matlab画图函数plot()/set/legend

    简单plot()/legend/XY轴范围axis 除了坐标轴信息外还可以添加其它的信息,如所画曲线的信息等:测试代码如下 x=0:pi/20:2*pi; y1=sin(x); y2=cos(x); ...

  10. MATLAB画图

    画图代码 clear % http://www.peteryu.ca/tutorials/matlab/visualize_decision_boundaries % load RankData % ...

随机推荐

  1. tomcat脚本

    !/bin/sh # eg: tomcat.sh start xxx # proc_dir="/usr/local/xxx/tomcat-zc-web/bin" proc_name ...

  2. js转换成字符串

    有两种方法: 1.对于boolean, number, string类型,可调用toString()方法 2.用String(var)方法 其中,第二种方法使用范围更广,可将没有toString()方 ...

  3. Primeng UI框架ionic3 中下拉选择插件p-dropdown 插件的使用方法

    1.html引入: <p-dropdown float-right [options]="sortOption" [(ngModel)]="sortNow" ...

  4. 【记录】@Configuration注解作用 mybatis @Param作用

    参考地址: 1:https://www.cnblogs.com/duanxz/p/7493276.html 2:https://www.wandouip.com/t5i91156/ 3:https:/ ...

  5. 某个应用的CPU使用率居然达到100%,我该怎么做?(三)

    某个应用的CPU使用率居然达到100%,我该怎么做?(三) 1. 引 你们好,可爱的小伙伴们^_^! 咱们最常用什么指标来描述系统的CPU性能呢?我想你的答案,可能不是平均负载,也不是CPU上下文切换 ...

  6. Linux系统测试端口连通性的方法

    Linux系统测试端口连通性的方法 有四种常用方法:1. telnet 方法2. wget 方法3. ssh 方法4. curl 方法 下面一一介绍. 1. telnet用法: telnet ip p ...

  7. python中函数用法

    unique() numpy.tolist() collections.defaultdict() random.sample()[] 1. unique():返回参数数组中所有不同的值,并按照从小到 ...

  8. 【Flutter学习】之动画实现原理浅析(三)

    一,概述 Flutter动画库的核心类是Animation对象,它生成指导动画的值,Animation对象指导动画的当前状态(例如,是开始.停止还是向前或者向后移动),但它不知道屏幕上显示的内容.动画 ...

  9. delphi 运行时提升软件到管理员权限

    //以管理员身份运行procedure RunAsAdmin(hWnd: HWND; aFile: string; aParameters: string);varsei: TShellExecute ...

  10. 前端每日实战:80# 视频演示如何用纯 CSS 创作一个自行车车轮

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/XBXEPK 可交互视频 此视频是可 ...