Y-axis is switching to 1.5 to -1.5 instead of -1.5 to 1.5? How do you fix this and modify data to match?

5 views (last 30 days)
% Plot the convergence array using the 'imagesc' command
figure;
imagesc(real(lower_left):spacing:real(upper_right), imag(lower_left):spacing:imag(upper_right), convergence_array);
colormap jet;
colorbar;
hold on;
% Plot the three roots as dots
scatter(real(roots_exact), imag(roots_exact), 'k', 'filled');
% Set the axis limits and labels
xlim([-2 2.5]);
ylim([-1.5 1.5]);
set(gca, 'YDir','reverse')
xlabel('Real Part');
ylabel('Imaginary Part');
title('Fractal: Basins of Attraction');
Unrecognized function or variable 'f'.

Accepted Answer

Steven Lord
Steven Lord on 7 Oct 2023
As written you're calling imagesc in its "high level" variant. See the "More About" section on that documentation page for more information. The reason that's relevant is because one of the axes properties the high-level variant of imagesc sets is "YDir to 'reverse'. Values along the y-axis increase from top to bottom. To decrease the values from top to bottom, set YDir to 'normal'. This setting reverses both the y-axis and the image."
One way to change the direction of the Y axis is to use the axis function with a ydirection input, axis xy.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!