Paint small Matlab Guide

I do not touch MATLAB found from time to time, until the time of need to use, simply feel unable to move, many commands are forgotten, so in this little drawing on the record about all aspects in MATLAB (# ^. ^ #)

plot (x, y, 'LineWidth ', 1.5);% bit lines thicker 

% is plotted scattergram Size sz 
Scatter (X, Y, sz, 'MarkerEdgeColor', [0 .5 .5], ... 
              'MarkerFaceColor ', [0 .7 .7], ... 
              ' LineWidth ', for 1.5) 

% of the title and the title coordinate axis 
title (' ***** ',' FontSize ', 18,' FontWeight ',' bold ')% The title bold font 
xlabel ( '*****', 'FontAngle ', 'italic');% may be italic 
ylabel ( '*****', 'FontAngle', 'Italic'); 


Axis ([400 , 2500,0,0.6]);% control range 
set (gca, 'YTick', [0: 0.1: 0.6]);% x -axis range, the interval 0.1 
SET (GCA, 'XTICK', [0: 500: 2500 ]);% y-axis range, the spacer 500 
SET (GCA, 'XTICK', [], 'YTick', []);% undesired ticks when 

set (gca, 'xticklabel', [])% undesired when the scale labeling 
set (gca, 'yticklabel ', []) 
yticklabel ', []) 
SET (GCA,' the FontName ',' Times New Roman ',' the FontSize ', 12 is); Font Scale Value% Attractive axis points
SET (GCA,' as linewidth ', for 1.5); Attractive% to FIG border 
set (gcf,' color ', [1,1,1])% white background

% color bar plus the colorbar 
colormap gray% change color mode 

% add text annotation 
text (0.011,0.58, '(d) 2016-06-15', 'FontName', 'Times New Roman', 'FontSize', 15); 
text (0.014,0.55, [ 'Y = ', num2str (p (1)), 'X +', num2str (p (2))], 'FontName', 'Times New Roman', 'FontSize', 11, ' FontAngle ',' italic '); the% num2str to show 

% legend 
legend ([p1 p2], { ' Fit line ',' 1: 1 Line '},' FontName ',' Times New Roman ',' Location ', 'southeast');% where p1 p2 represent two different plot lines drawn objects used herein 

% output pattern 
print ( 'Figure1', '- dpdf', '- r300');% to the current output pdf folder, or a simple line graph in pdf eps (-deps), AI open edit 
print ( 'Figure2', '- djpeg', '- r600');% output jpg, complex, large quantity of data with color pictures jpg, 600 ppi 
the SaveAs ( 'Figure1 ', [' D: \ 'the Name],' PDF ') 

% saved pattern to the current directory  
print ( 'fileformat', '- r + resolution ',' filename ')
Print (' - djpeg ',' - R600 ',' Bon ') 
Print (' - djpeg ',' - R900 ', 'ALA & FVC')

 

name: value parameter settings:

 

 

 

 

 

DatetimeTickFormat The value Examples
'yyyy-MM-dd' 2014-04-19
'dd/MM/yyyy' 19/04/2014
'dd.MM.yyyy' 19.04.2014
'yyyy年 MM月 dd日' 2014年 04月 19日
'MMMM d, yyyy' April 19, 2014
'eeee, MMMM d, yyyy HH:mm:ss' Saturday, April 19, 2014 21:41:06
'MMMM d, yyyy HH:mm:ss Z' April 19, 2014 21:41:06 -0400

 

DurationTickFormat The value Explanation
'y' Determining a number of fine long. Fixed length equal to 365.2425 days a year.
'd' Determining a number of fine long days. Fixed length equal to 24 hours a day.
'h' Hours
'm' The number of minutes
's' The number of seconds

 

 

# Linear fit plus 
HOLD ON 
P = polyfit (X, Y,. 1);% linear fit of 
m = 0: 0.01: 0.6; 
X1 = linspace (min (X), max (X));   
Y1 = polyval ( P, X1);   
P1 = Plot (X1, Y1, '- K', 'as linewidth', 1.2);

Object-oriented drawing style

The so-called object-oriented style of drawing, is modeled from real life, unlike procedural drawing mode.

  • Create a figure object. Spread blank canvas
  • Creating axes object. A drawing area is selected from the canvas
  • Create a line object. · Draw in the drawing area
  • Create a legend object.
  • Save image

Various objects have different properties, is plotted on the graph is essentially refined learn to set various properties

Tips:

  • Please set the drawing size in advance (based on the layout of your paper needs), all font styles.
  • Output pdf / eps / JPG , above the print output, and then open the file with editorial changes AI, export to / Save As with the AI ...
  • The visio / word document into a pdf, please use  Acrobat PDFMaker , it is not recommended to use built-in Save As or printed as a pdf (there are many details)
F = Figure; 
Pl = Plot (X, Y, '-', 'the lineWidth', 1.2, 'Color', [0.8 0.3 0.5]);% create graphic objects Pl 
HOLD ON; 
P2 = Plot (X, Y2, ' - ',' lineWidth ', 1.2 ,' color ', [0.1 0.3 0.5]);% create graphic objects P2 

axis ([Xmin Ymin Xmax Ymax]) =% XY-axis range. 1 1pt / 72inch. 1 inch = 25.4mm 
the xlabel ( 'Torque $ m_x $ (Nm) ', 'interpreter', 'latex', 'FontSize', 8);% Latex format label 
ylabel ( '******', 'Fontname', 'Times New Roman' , 'the FontSize',. 8); 

width = 240;% 240pt US Letter bis column 
set (gcf, 'unit', 'points', 'PaperUnits', 'points', 'PaperPosition', [0,0,240,240 / 5 * 4 ], ... 
    'position', [500 300 240 240 / *. 4. 5], 'Color', 'W', 'the PaperSize', [width,width / *. 4. 5]); 

SET (GCA, 'Fontname', 'Times New Roman', 'fontSize',. 8);% handle axis, the axis scale is provided a digital pattern
L1 = legend ([P1 P2] , 'Actual torque', 'Fake'); % name objects to create a legend in the legend 
set (L1, 'Location', 'northeast', 'Orientation', 'vertical', .. . 
    'Fontname', 'Times New Roman', 'the FontSize',. 8, 'the TextColor', 'Black');% Legend formats 

% to output graphics to a file 
print ( 'Figure1', '- dpdf', '- r300') ;% output pdf, or a simple line graph in pdf eps (-deps), AI open edit 
print ( 'Figure2', '- djpeg', '- r600');% output jpg, complex, color images with a large amount of data JPG, 600 ppi 

% ---------------------------------------- 

% figure created objects 
Fig = Figure (... 
    'Units',' pixels', ... 
    'the Name', 'Move2', ... 
    'NumberTitle', 'OFF', ... 
    'IntegerHandle ',' OFF '); 
% axes created object set axis properties 
AxesH = axes (... 
    ' the Parent ', Fig, ... 
    ' XLIM ', [50 -10], ...
    'Ylim', [40 -10], ... 
    'Xgrid', 'ON', ... 
    'YGRID', 'ON', ... 
    'DataAspectRatio', [. 1. 1. 1], ... 
    'the Visible ',' ON '); 

T = linspace (0,45,101) * PI / 180 [; 
X = 40 * COS (T); 
Y = 40 * SiN (T); 
RealTrace = Line (AxesH, X, Y,' as linewidth ', 2); 
precisetrace = Line (AxesH, [X (. 1) X (End)], [Y (. 1) Y (End)], ... 
                    ' Color ',' G ', ... 
                    ' as linewidth ' , 2, ... 
                    'lineStyle', '-'); 

Legend (AxesH, [RealTrace, precisetrace], ... 
    'real trajectory', 'precise trajectory', ... 
    'LOCATION', 'Northwest ');
% Specifies the path and format 
saveas (Fig, [ 'D: \ abc \' Fig.Name], 'pdf')

  

reference:

https://www.zhihu.com/question/269326720/answer/347245807

https://www.zhihu.com/question/269326720/answer/347554215

https://ww2.mathworks.cn/help/matlab/ref/plot.html

Guess you like

Origin www.cnblogs.com/icydengyw/p/12606255.html