Children of axes after using yyaxis right

6 次查看(过去 30 天)
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)

采纳的回答

Adam Danz
Adam Danz 2023-6-19
% 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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by