Plotting different chart types in the same figure?
2 次查看(过去 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!