plotyy : align y axes at zero
Afficher commentaires plus anciens
When using plotyy I need to plot two different series. One on the left y axis, and the other on the right y axis. Both series contain numbers in different scales. The one of the left contains numbers from 0 to (potentially) Infinity, but the one on the right is restricted to the range -1, 1. In the code below, you can see an example.
I'd like to make sure that both axes cross at y = 0, but I'm not sure how to do it. In the example I included, you can see that the two y axes are misaligned.
Thanks in advance
x = 15;
fn1 = @(x, y) bar(x, y, 0.3, 'FaceColor', 'blue');
fn2 = @(x, y) bar(x, y, 0.3, 'FaceColor', 'red');
figure;
plotyy( [1:x]-1, rand(x, 1) * 100, [1:x]+1, 2 * rand(x, 1) - 1, fn1, fn2)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Combine Multiple Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!