How to make inset figure with two y-axes
5 次查看(过去 30 天)
显示 更早的评论
I can make a figure with two y-axes, using yyaxis left and yyaxis right. See here, for instance. This results in a plot where the left and right y-axes have different colors, and so do the associated data. Now, I want to use this as an inset in another figure. I try something like this:
% initial plot
plot(d(:,1),d(:,2))
% make the inset
axes('Position',[0.4,0.7,0.2,0.2])
box on
% double y-axes for the inset
yyaxis left
scatter(d2x,d2y,'x','linewidth',2)
yyaxis right
scatter(d3x,d3y,'linewidth',2)
However, this results in the proper left and right axis colors from disappearing. All data points in the inset appear the same color, so do both the y-axes. How can I do this properly?
0 个评论
采纳的回答
Voss
2022-7-29
Seems to be ok:
% initial plot
plot(rand(1,10),rand(1,10))
% make the inset
axes('Position',[0.4,0.7,0.2,0.2])
box on
% double y-axes for the inset
yyaxis left
scatter(rand(1,5),rand(1,5),'x','linewidth',2)
yyaxis right
scatter(rand(1,5),rand(1,5),'linewidth',2)
Is the code you posted the actual code you are running, which has the problem? Or is it some illustrative example code? If it's only an example, please share the actual code that has the problematic behavior.
2 个评论
Voss
2022-7-29
Maybe set the colororder for the inset axes separately:
for i=1:30
plot(rand(1,10),rand(1,10))
hold on
end
colororder(jet(30))
% make the inset
ax = axes('Position',[0.4,0.7,0.2,0.2]);
colororder(ax,[0 0 1; 1 0 0]) % blue, red
box on
% double y-axes for the inset
yyaxis left
scatter(rand(1,5),rand(1,5),'x','linewidth',2)
yyaxis right
scatter(rand(1,5),rand(1,5),'linewidth',2)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!