Children of axes after using yyaxis right

6 views (last 30 days)
Why does children not include a and how would I get a(only using ax, b or c)?
% Create the axes object
ax = axes();
% Plot 'a' and 'b' using the same axes
a = plot(ax, 1:10, 1:10, 'DisplayName', 'Test');
yyaxis right
b = plot(ax, 1:10, ones(10, 1), 'DisplayName', 'TestRight');
hold on
c = plot(ax, 1:10, 0.5*ones(10,1), 'DisplayName', 'TestRight2');
% Access the children of the parent object
children = ax.Children
children =
2×1 Line array: Line (TestRight2) Line (TestRight)

Accepted Answer

Adam Danz
Adam Danz on 19 Jun 2023
% Create the axes object
ax = axes();
% Plot 'a' and 'b' using the same axes
a = plot(ax, 1:10, 1:10, 'DisplayName', 'Test');
yyaxis right
b = plot(ax, 1:10, ones(10, 1), 'DisplayName', 'TestRight');
hold on
c = plot(ax, 1:10, 0.5*ones(10,1), 'DisplayName', 'TestRight2');
% Access the children of the parent object
yyaxis left
children = ax.Children
children =
Line (Test) with properties: Color: [0 0.4470 0.7410] LineStyle: '-' LineWidth: 0.5000 Marker: 'none' MarkerSize: 6 MarkerFaceColor: 'none' XData: [1 2 3 4 5 6 7 8 9 10] YData: [1 2 3 4 5 6 7 8 9 10] Show all properties

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!