using matlab drawing line graph for latex
2017-10-23 19:32
711 查看
https://www.youtube.com/watch?v=zdbNhK7FsBg
原始画图代码Horse_D = [5.33 5.73 5.97 5.72 4.21 5.70 5.80]; Horse_A = [9.62 13.57 12.39 16.13 14.74 10.68 22.04]; Horse_B = [11.21 14.13 13.94 17.87 9.82 4.61 17.46]; Horse_I = [0 4 19 38 8 0 18]; x = [1:7]; plot(x, Horse_D, x, Horse_A, x, Horse_B, x, Horse_I); set(gca,'XTick',1:7,'XTickLabel',{'CASAP','ACAP','ASAP','ED','SM-ASAP','LSE','PDS'})
然后打绘图工具, 我们在里面编辑颜色, 线条, 标记等等, 编辑好后可以存成png, fig等等, 但是为了给下一组数据使用, 我们可以生成对应的代码
在绘图工具的 菜单-> 文件下面会有一个 生成代码,
function createfigure(X1, YMatrix1) %CREATEFIGURE(X1, YMATRIX1) % X1: x 数据的矢量 % YMATRIX1: y 数据的矩阵 % 由 MATLAB 于 23-Oct-2017 12:27:55 自动生成 % 创建 figure figure; % 创建 axes axes1 = axes; hold(axes1,'on'); % 使用 plot 的矩阵输入创建多行 plot1 = plot(X1,YMatrix1); set(plot1(1),'DisplayName','Distance error','Marker','v','Color',[0 0 1]); set(plot1(2),'DisplayName','Angle error','Marker','+','Color',[1 0 0]); set(plot1(3),'DisplayName','Bending error','Marker','o','Color',[1 0 1]); set(plot1(4),'DisplayName','Intersection error','Marker','x',... 'Color',[0 1 0]); % 创建 title title('Errors in horse example'); box(axes1,'on'); grid(axes1,'on'); % 设置其余坐标轴属性 set(axes1,'XTick',[1 2 3 4 5 6 7],'XTickLabel',... {'CASAP','ACAP','ASAP','ED','SM-ASAP','LSE','PDS'}); % 创建 legend legend1 = legend(axes1,'show'); set(legend1,... 'Position',[0.421052633200964 0.44293924622935 0.157894733598073 0.1141215075413]);
比如我这里
然后调用的时候
Horse_D = [5.33 5.73 5.97 5.72 4.21 5.70 5.80]; Horse_A = [9.62 13.57 12.39 16.13 14.74 10.68 22.04]; Horse_B = [11.21 14.13 13.94 17.87 9.82 4.61 17.46]; Horse_I = [0 4 19 38 8 0 18]; x = [1:7]; createfigure(x, [Horse_D; Horse_A; Horse_B; Horse_I]);
就可以产生在绘图工具里编辑出来的效果
这样就不用每次都在工具里面手工调, 而是用代码生成
相关文章推荐
- Animated Line Graphs / Sparklines using SVG Pat...
- matlab中图像处理出现Error using isrgb (line 8)Function ISRGB has been removed.
- using tail recursion to reverse words of line ( just for fun)
- Drawing Graphs using Dot and Graphviz
- GCMex - MATLAB wrapper for graph cuts multi-label energy min
- MATLAB读取写入文本数据最佳方法 | Best Method for Loading & Saving Text Data Using MATLAB
- ERROR 1045 (28000) at line 2: Access denied for user 'root'@'%' (using password: YES)
- Matlab出现On Startup: Error using eval undefined function 'workspacefunc' for input arguments of type
- matlab出现错误: Error using xlsread (line 247)Error: 服务器出现意外情况。
- window系统命令行设置proxy----Setting a proxy for Windows using the command-line
- Line Graph with Dual-scaled Axes using SVG and ...
- Matlab出现On Startup: Error using eval undefined function 'workspacefunc' for input arguments of type
- Using the this API wsh_deliveries_pub.Delivery_Action to ship confirm for the delvery
- 总结linux下使用mysql数据库出现 “Access denied for user 'root'@'localhost' (using password: YES)”
- error: 'Access denied for user 'root'@'localhost' (using password: NO)'
- Brand Selection of Quarry Crusher for Production Line
- 【Unity Shaders】Using Textures for Effects —— 实现Photoshop的色阶效果
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题的解决办法
- windows 8 安装 oracle 11g 报错:command line option syntax error,type command/? for help