Code covered by the BSD License

### Highlights from PlotAxisAtOrigin

3.09091
3.1 | 12 ratings Rate this file 134 Downloads (last 30 days) File Size: 1.47 KB File ID: #10473 Version: 1.0

# PlotAxisAtOrigin

### Shanrong Zhang (view profile)

21 Mar 2006 (Updated )

This is a 2D vresion of Plot3AxisAtOrigin, which may be used to plot axis at origin.

### Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

File Information
Description

PlotAxisAtOrigin Plot 2D axes through the origin. It is a 2D version of Plot3AxisAtOrigin written by Michael Robbins. Have fun!

Acknowledgements

Plot3axisatorigin inspired this file.

This file inspired Axescenter.

MATLAB release MATLAB 7.1.0 (R14SP3)
21 Apr 2015 Isabella Osetinsky-Tzidaki

### Isabella Osetinsky-Tzidaki (view profile)

Dear Shanrong Zhang,

along with a slight change in the second active line: H=plot(x,y);

It allows handling of the figure:
function H=PlotAxisAtOrigin(x,y)
%
% Example:
% x = -2*pi:pi/10:2*pi;
% y1 = sin(x);
% y2 = cos(x);
% y = [y1;y2];
% H=PlotAxisAtOrigin(x,y);
% H(1).LineWidth = 3;
% H(2).Marker = '*';
% H(2).Color = 'm';
%

% PLOT
if nargin == 2
H=plot(x,y);
%--contunue as in your original code ----

21 Apr 2015 Isabella Osetinsky-Tzidaki

### Isabella Osetinsky-Tzidaki (view profile)

works just as needed. Thank a lot!

30 Dec 2014 zhao

### zhao (view profile)

when x and y doesn't contain zero , for example x=5:0.1:10; y=2*x . the function will not work

27 Jun 2014 Jan

### Jan (view profile)

@Anael:

- Hide in comment line containing set(gcf,'color','w')

@Markus Buehren:
- It doesn't work because "Axes in origin" are actually lines in regular axes, which are hidden.

I'm thinking of writing function AxesToOrigin based on this function...

Comment only
04 Apr 2014 Anael

### Anael (view profile)

Great function!
-I don't like that it changes the background color.
-I wish it wouldn't need to take any arguments.

19 May 2013 Bob

07 Apr 2013 Sam

### Sam (view profile)

Hello, I can not understand how to apply this to my code. I want to shift the current origin to (0,0) from (-0.3, 0) but the -y axis should not appear. My code is:

% Plot for lambda = 0.5

n = 30;

dc1 = 1/30*(0.5*66+0.5*62);
dc2 = 1/30*(0.5*57+0.5*55);

dn1 = 1/30*(0.5*40+0.5*30);
dn2 = 1/30*(0.5*35+0.5*20);
dn3 = 1/30*(0.5*20+0.5*27);

e = -0.3:0.01:0.3;

bc1 = 30*dc1*(1+(dc1./(10+e)));
bc2 = 30*dc2*(1+(dc2./(10+e)));

bn1 = 30*dn1*(1+(dn1./(2+e)));
bn2 = 30*dn2*(1+(dn2./(2+e)));
bn3 = 30*dn3*(1+(dn3./(2+e)));

plot(e, bc1, 'g')
hold all
plot(e, bc2, 'r')
hold all
plot(e, bn1, 'b')
hold all
plot(e, bn2, 'y')
hold all
plot(e, bn3, 'black')

set(gca,'XTick',-0.3:0.1:0.3)

set(gca,'XTickLabel',{'-0.3','-0.2','-0.1','0','0.1', '0.2', '0.3'})

ylim([0 90]);
xlim([-0.3 0.3]);

title('BED Plots for Organs');
xlabel('Epsilon range of alpha/beta');
ylabel('BED');

%Thank you very much!

14 Jun 2012 David Polcari

### David Polcari (view profile)

Hi this is great but what do I do if I want to add axis labels?

Comment only
06 Jun 2012 zhang yanyu

### zhang yanyu (view profile)

24 Nov 2011 chen Jian

### chen Jian (view profile)

15 Apr 2010 Charles

### Charles (view profile)

I tried it. Works fine for me. Exactly what I wanted. Thanks for sharing

Comment only
30 Mar 2009 Christian

### Christian (view profile)

09 Feb 2009 Markus Buehren

### Markus Buehren (view profile)

Sorry, but I think this package is not very useful. On the first view it looks nice, but the axis will not change when zooming in etc.

Markus

16 Nov 2006 guillaume mille
13 Oct 2006 Jinwei Gu