plotyn(varargin)

버전 1.4.0.0 (7.48 KB) 작성자: Jakub Nedbal
Plots graphs with arbitrary number of Y-axes. Generalization of plotyy.
다운로드 수: 1.1K
업데이트 날짜: 2015/4/17

라이선스 보기

plotyn Extends plot to create a separate Y-axis for each dataset. It is a generalization of Matlab's inbuilt function PLOTYY.
Creation mode, needs to be run first:
Syntax: [hax, hlines, data] = plot4y(data)
Syntax: [hax, hlines, data] = plot4y(data, pos)
Syntax: [hax, hlines, data] = plot4y(data, pos, parent)

Update mode, to be performed on existing axes to update their plots, colors or Y-axis labels:
Syntax: plot4y(hax, hlines, data)

Inputs:
data is a struct with at least two fields (X, Y). The dimensionality of data determines the number of graphs:
* data(1).X X coordinates of first dataset (Same for all)
* data(i).Y Y coordinates of i-th dataset
* data(i).Color Color of i-th dataset (Optional)
* data(i).YLabel Y-axis label of i-th dataset (Optional)

* pos Array of 5 numbers positioning the axes on the current figure (handle) in 'Pixel' units
* parent Handle onto which the axes are drawn

Outputs:
* hax Double array containing the axes' handles
* hlines Double array containing the lines' handles
* data Struct with the input data

Example:
x = 0 : 10; data(1).X = x;
data(1).Y = x .^ 1; data(1).YLabel = 'First Y-axis';
data(2).Y = x .^ 2; data(2).YLabel = 'Second Y-axis';
data(3).Y = x .^ 3; data(3).YLabel = 'Third Y-axis';
data(4).Y = x .^ 4; data(4).YLabel = 'Fourth Y-axis';
figure;
[hax, hlines, data] = plotyn(data);
legend(hlines, 'y = x', 'y = x^2', 'y = x^3', 'y = x^4', 2, 'Location', 'NorthWest');

Now, the data in the graph can be changed for example in datasets 2 and 3:

data(2).Y = x .^ (1 / 2);
data(3).Y = x .^ (1 / 3);
plotyn(hax, hlines, data)

See also plot, plotyy

Based on:
plotyyy.m by Denis Gilbert, Ph.D.
ploty4.m by Peter (PB) Bodin

Created by modification of the aforementioned functions by:

Jakub Nedbal
April 2015
Distributed under BSD license.

인용 양식

Jakub Nedbal (2024). plotyn(varargin) (https://www.mathworks.com/matlabcentral/fileexchange/50542-plotyn-varargin), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2014b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Two y-axis에 대해 자세히 알아보기
태그 태그 추가
도움

받음: plotyyy, ploty4.m

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.4.0.0

Added updated file with fixed help section.

1.3.0.0

Another refinement of the description.

1.2.0.0

Further improved the description.

1.1.0.0

Fixed the description.

1.0.0.0