Rick T
Rick T

Reputation: 3389

Matlab / Octave and Compass with no arrows and changing line style

I have code that will plot a compass plot in octave (3.2.4) /matlab but how do I get rid of the arrows / change color

[x,y]=pol2cart(90*pi/180,1);
compass(x,y) 

I tried

[x,y]=pol2cart(90*pi/180,1);
compass(x,y,'*')

and

[x,y]=pol2cart(90*pi/180,1);
compass(x,y,'--r') 

along with several combinations any idea?

Thanks

Upvotes: 0

Views: 1757

Answers (1)

H.Muster
H.Muster

Reputation: 9317

To delete the arrows you need to delete all but the first two entries in the xdata and ydata fields of the plot. The color can be changed by setting the color property. Please find below a solution for compass plots with arbitrary numbers of arrows.

[x,y]=pol2cart([45 90]*pi/180,1);

h = compass(x,y);

for k = 1:length(h)
    a = get(h(k), 'xdata'); 
    b = get(h(k), 'ydata'); 

    set(h(k), 'xdata', a(1:2), 'ydata', b(1:2), 'color', 'r')
end

Upvotes: 2

Related Questions