Search

[MATLAB: Function] PlotSetting

Category
Tools & Utils
Kewords
MATLAB
Function
Plot
3 more properties

PlotSetting

Statement

[Fig, Axes] = PlotSetting(w, h)
Inputs:
w: width of the figure window
h: height of the figure window
Outputs:
Fig: graphic handle object of the figure
Axes: graphic handle object of the figure’s axes

Source Code of Function M-File

function [Fig, Axes] = PlotSetting(w, h) % Graphic Handle Object Fig = figure(); Axes = axes(Fig); grid on; hold on; % Custom Color Order color_order = [0.20, 0.20, 0.92; % Blue 0.92, 0.20, 0.20; % Red 0.10, 0.80, 0.10; % Green 0.24, 0.16, 0.24; 0.94, 0.75, 0.20; 0.68, 0.15, 0.68; 0.85, 0.85, 0.20; 0.30, 0.75, 0.90; 0.60, 0.10, 0.20]; % Setting set(Fig, 'Position', [960 - 0.5*w, 520 - 0.5*h, w, h], ... 'Color', [1, 1, 1]); set(Axes, 'FontSize', 18, ... 'FontWeight', 'bold', ... 'TitleFontWeight', 'bold', ... 'ColorOrder', color_order, ... 'LabelFontSizeMultiplier', 1.2, ... 'TitleFontSizeMultiplier', 1.4, ... 'LineWidth', 1.2)
MATLAB
복사

Example

% Sine & Cosine Functions x = linspace(0, 2*pi, 100); y1 = sin(x); y2 = cos(x); % Plot [Fig, Axes] = PlotSetting(1000, 800); plot(x, y1, 'LineWidth', 1.5); plot(x, y2, 'LineWidth', 1.5); axis([-0.01, 2*pi + 0.01, -1.1, 1.1]); title('Sinusoidal Functions'); xlabel('x'); ylabel('y'); legend({'Sine','Cosine'}, 'FontSize', 15, 'FontWeight', 'bold', 'Location', 'northoutside', 'NumColumns', 2, 'Orientation', 'horizontal');
MATLAB
복사