Boxplot: second Y axes labels
古いコメントを表示
How can i put the same labels also on both left and right Y axes (tried several solutions but can't make them work as I wish)?
boxplot(rand(100,10))
Thanks
Oleg
採用された回答
その他の回答 (3 件)
Matt Fig
2011 年 3 月 19 日
0 投票
Hey Oleg, I don't have the Stats toolbox so I can't try it out. But I have an idea. Make one figure with plotyy, then make another with the boxplot you want. Then either COPYOBJ the boxplot over to the plotyy figure or set the parent property of the boxplot to one of the plotyy axes. It might be worth a try...
4 件のコメント
Oleg Komarov
2011 年 3 月 19 日
Jiro Doke
2011 年 3 月 19 日
Nice. I think that may work. You may also need to "synch" the left and right axes because plotyy sets the ticks for left and right based on the data that is plotted. If you just copy the data on one of the axes, the ticks may not line up. I suppose you can copy the data from boxplot on both the axes.
Oleg Komarov
2011 年 3 月 19 日
Jiro Doke
2011 年 3 月 19 日
Yeah, I noticed that. I would go with my solution above, because that uses boxplot as is. Even though the x labels are text objects, they do the "right thing" even when you zoom in and out.
Elena
2011 年 6 月 5 日
0 投票
also a bit of a workaround: make a plotyy where one the first dataset is empty or all zeros, then use 'hold on' to plot the boxplot over top.
Hussein
2023 年 8 月 20 日
0 投票
Try this code please
% Create some sample data x = 1:10; y1 = rand(1, 10); y2 = rand(1, 10) * 100;
% Plot the first dataset figure; plot(x, y1, 'b-'); xlabel('X'); ylabel('Y1', 'Color', 'b');
% Add a second Y-axis yyaxis right;
% Plot the second dataset plot(x, y2, 'r-'); ylabel('Y2', 'Color', 'r');
% Set the color of the tick labels for the right Y-axis ax = gca; ax.YAxis(2).Color = 'r';
% Add a legend legend('Y1', 'Y2');
カテゴリ
ヘルプ センター および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!