How to make inset figure with two y-axes
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Voss
il 29 Lug 2022
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 Commenti
Voss
il 29 Lug 2022
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)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!