I want to plot multiple lines on loglog axes on one figure, something like:
figure(3)
clf('reset')
hold on
loglog(t1, g1, 'r')
loglog(t2, g2, 'b')
loglog(t3, g3, 'Color', [0 .5, 0])
hold off
xlabel('$$t$$','Interpreter','latex')
ylabel('$$g$$','Interpreter','latex')
I know if I use colours that have a matlab shortcut, i.e. use 'g' for plotting g3 for example, I could plot these all in
loglog(t1, g1, 'r', t2, g2, 'b', t3, g3, 'g')
without using hold. But I've previously used the first colour scheme for my data and would like to avoid having to change all my previously saved figures.
Does anyone know a way to make the three curves different colours on loglog axes using colours that don't have a short name in Matlab?

댓글 수: 2

Michael
Michael 2023년 11월 22일
I am not sure if I understand your question correctly but maybe a solution could be to invoke the line 'hold on' after the first loglog.. command?
Star Strider
Star Strider 2023년 11월 22일
Does anyone know a way to make the three curves different colours on loglog axes using colours that don't have a short name in Matlab?
You can create your own colormap. See Colormap Editor for one way to create one you want. You can then use specific rows of the colormap to define specific colours.

댓글을 달려면 로그인하십시오.

 채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 22일

0 개 추천

You can use colororder paired with RGB Triplets -
x = logspace(-1,2);
y1 = 10.^x;
y2 = 1./10.^x;
y3 = 1.^x;
figure
loglog(x,y1,x,y2,x,y3)
grid on
legend({'y1', 'y2', 'y3'})
figure
l = loglog(x,y1,x,y2,x,y3);
%Define RGB triplets
map = hsv(numel(l))
map = 3×3
1 0 0 0 1 0 0 0 1
%Set the colororder
colororder(map)
grid on
legend({'y1', 'y2', 'y3'})
I have used colormap to get colors. You can also define RGB triplets manually, or get random values via rand.
Additionally, if you are working with R2023b, you can use different built-in pallettes.

댓글 수: 2

Sarah Murphy
Sarah Murphy 2023년 11월 24일
Thanks very much!
Dyuman Joshi
Dyuman Joshi 2023년 11월 24일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Log Plots에 대해 자세히 알아보기

제품

태그

질문:

2023년 11월 22일

댓글:

2023년 11월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by