Plotting different chart types in the same figure?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello Matlab community. I am a basic Matlab user and I am very interested about plotting in Matlab.
I would like to know if is it possible to plot different chart types in the same figure? And if yes, how to do it?
Here's an example: Let's suppose I would like to plot an Histogram to compare different data.
At the same time I have a specification limit for the data I am analysing and I would like to plot the limit as a continuous line in the same chart just to check if any histogram bars would pass it.
Thank you in advance.
댓글 수: 0
답변 (3개)
Jan
2015년 11월 16일
You can create either different axes objects directly using the axes('Position', [X, Y, W, H]]) command. Or the subplot() command does this also internally, but uses an easier syntax to determin the positions. Reading the documentation for the commands will help, most of all the examples there.
댓글 수: 0
Star Strider
2015년 11월 16일
To plot two different plots on the same axes, use the hold function:
figure(1)
histogram( ... )
hold on
plot(xlim, [1 1]*limit_line_value,'-r')
hold off
댓글 수: 0
Yazan
2021년 7월 13일
편집: Yazan
2021년 7월 13일
There are several ways to obtain that. One of them is through creating panels, each with its own axes. You can plot on the axes separately. Remember, pannels are children of a figure (or a uitab), the axes are children of a panel, and the data are children of the axes. An example is provided below, which plots the histogram of a random vector and the data itself on different panels.
% figure: father of the panels
f = figure;
% panels: children of a figure and father to axes
p1 = uipanel(f, 'Position', [0 0 0.5 1], 'Title', 'First panel', 'TitlePosition', 'centertop');
p2 = uipanel(f, 'Position', [0.5 0 0.5 1], 'Title', 'Second Panel', 'TitlePosition', 'centertop');
x = randn(128, 1);
% create axes on each panel
ax1 = axes(p1);
% specify the axes on which to plot the histogram
histogram(ax1, x);
xlabel(ax1, 'Bins'); ylabel(ax1, 'Histogram');
ax2 = axes(p2);
% specify the axes on which to plot the data
plot(ax2, x);
xlabel(ax2, 'Index'); ylabel(ax2, 'Data');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!