I am trying to break the y-axis of a plot and put Infinity as my top point, but I can't seem to modify the y-axis labels. Ideally, I'd also like to get rid of that curve ~ line that breaks the plot and instead use the double slashes //, but I tried using a bunch of the break axis functions on the matlab file exchange and I couldn't get them to work for me. However, I'd really also like to be able to compare the look of both methods, so I'd like to be able to see how both ways would look.
I want to replace the "600" in the figure below with the word "Infinity" on a broken axis..
I'm using the function breakyaxis.m
Here is my code:
close all;
clc;
figure
% Plot
hold on; plot([0 .2 .5 .8 1],[-10 0 50 100 300],'.','MarkerSize',10); %(:,exp_width)); hold on;
plot(.4,150,'+','MarkerSize',10,'MarkerFaceColor','black');
plot(1,600,'+','MarkerSize',10,'MarkerFaceColor','black'); % Set 600 as point where y value should really be infinity
breakyaxis([350 550]); % Break Axis
xlabel('X Axis'); ylabel('Y Axis');
set(gca,'yticklabel',sprintf('%10s',[num2str(-10) num2str(0) num2str(100) 'inf']));
hold off;
Here is a picture of my figure at the moment:
Looking at the code for the function breakyaxis
(type edit breakyaxis
in the Command Window) we see that we can actually call the function with an output argument, named breakInfo
, which is a structure containing a bunch of information about the 4 axes created in the function.
The axes called highAxes
is the one containing the YTickLabel
600, which you want to replace with 'Infinity'.
Therefore, assign an output when calling breakyaxis
as follows:
breakInfo = breakyaxis([350 550]);
And add this line:
set(breakInfo.highAxes,'YTicklabel','Infinity')
The plot then looks like this: