Getting the right colorbar to show in plot

1 view (last 30 days)
Hello, I am trying to make the right colorbar to show in a plot.
This is my plot right now
figure()
cqfactor=qfactor./max(max(qfactor));
plot3(Evlon,Evlat,-Evdep,'o');
hold on
plot3(Stalon,Stalat,-Stadep,'rv');
grid on
hold on
for i=1:length(Evlon)
for j=1:length(Stalon)
P1=[Evlon(i),Evlat(i),-Evdep(i)];
P2=[Stalon(j),Stalat(j),Stadep(j)];
pts = [P1; P2];
if cqfactor(i,j)>0
plot3(pts(:,1), pts(:,2), pts(:,3),'Color',[1,0,cqfactor(i,j)])
end
hold on
end
end
colorbar()
hold off
Which plots almost everything I want to plot.
Evlon, Evlat,Evdep, Stalon,Stalat and Stadep are just vectors with x,y,z coordinates for events and stations. I have lines connecting these plots and the colors of these lines vary in RGB like [1,0,cqfactor(i,j)], so I need a colorbar that does the same thing. How do I do this?
Thanks in advance

Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!