How do I plot a candle graph on top of an area graph when calling the CANDLE function before the AREA function?

2 views (last 30 days)
I would like to plot a candle graph on top of an area graph. However, I prefer to call the CANDLE function before I call the AREA function. When I do this, the area graph covers the candle graph completely. How do I ensure that the candle graph is seen as well?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The following code demonstrates an example of plotting a candle graph on top of an area graph when calling the CANDLE function before the AREA function:
close all;
%%Plot candle on a2 axes
a2 = axes;
High = [5 7 6 4]';
Low = [2 3 2 1]';
Close = [3 4 3 2]';
Open = [4 3 6 3]';
candle(High, Low, Close, Open);
%%Plot area on a1 axes
a1 = axes;
x = linspace(0, 4, 100);
y = 8*rand(1, 100);
area(x, y);
%%Make sure a2 is on top
set(gcf, 'Children', [a2; a1])
%%Make second axes invisible
set(a2, 'Visible', 'off');
%%Link the axes limits
linkaxes([a1 a2], 'xy');
%%Adjust the limits
ylim([0 10]);

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!