How to change color of berfit curve
조회 수: 9 (최근 30일)
이전 댓글 표시
How do I change the color of a berfit plot? I have two fits that I am plotting on the same graph, and I would like to change the symbol color/shape and line color. I have tried the standard plot color formatting and it hasn't worked and can't find a solution anywhere. I have two arrays of random data to show you the structure of my code:
Temp_x = [
9
8
7
6
5
4
3
];
Temp_y = [
1e-3
5e-3
1e-2
2e-2
3e-2
5e-2
1e-1
];
Temp_y2 = [
2e-3
6e-3
2e-2
3e-2
4e-2
6e-2
1.1e-1
];
figure;
berfit(fliplr(Temp_x'),fliplr(Temp_y')); %transpose and flip data so it would be in the right order for berfit
hold on;
berfit(fliplr(Temp_x'),fliplr(Temp_y2'))
legend('Tempy','Curve Fit', 'Tempy2', 'Curve Fit')
title('Temp Title')
subtitle('Temp Subtitle')
axis([1 15 1e-4 .1])
hold off;
The plot shows this:
댓글 수: 0
채택된 답변
Voss
2024년 5월 23일
Temp_x = [
9
8
7
6
5
4
3
];
Temp_y = [
1e-3
5e-3
1e-2
2e-2
3e-2
5e-2
1e-1
];
Temp_y2 = [
2e-3
6e-3
2e-2
3e-2
4e-2
6e-2
1.1e-1
];
figure;
berfit(fliplr(Temp_x'),fliplr(Temp_y')) %transpose and flip data so it would be in the right order for berfit
hold on;
berfit(fliplr(Temp_x'),fliplr(Temp_y2'))
legend('Tempy','Curve Fit', 'Tempy2', 'Curve Fit')
title('Temp Title')
subtitle('Temp Subtitle')
axis([1 15 1e-4 .1])
hold off;
Get the plotted lines:
h = findobj(gcf,'Type','line')
Set their colors:
h(1).Color = 'b';
h(2).Color = 'r';
h(3).Color = 'k';
h(4).Color = [0 0.6 0];
댓글 수: 0
추가 답변 (1개)
Les Beckham
2024년 5월 23일
You can capture the fit data from berfit and use the normal plot command to plot the data with full control over the symbols, lines, and colors.
Temp_x = [
9
8
7
6
5
4
3
];
Temp_y = [
1e-3
5e-3
1e-2
2e-2
3e-2
5e-2
1e-1
];
Temp_y2 = [
2e-3
6e-3
2e-2
3e-2
4e-2
6e-2
1.1e-1
];
figure;
Temp_x = fliplr(Temp_x'); %transpose and flip data so it would be in the right order for berfit
Temp_y = fliplr(Temp_y');
Temp_y2 = fliplr(Temp_y2');
ber1 = berfit(Temp_x, Temp_y)
ber2 = berfit(Temp_x, Temp_y2);
hp = plot(Temp_x, Temp_y, 'bx', Temp_x, ber1, 'b-', Temp_x, Temp_y2, 'rx', Temp_x, ber2, 'r-');
set(gca, 'YScale', 'log')
grid on
legend('Tempy','Curve Fit', 'Tempy2', 'Curve Fit')
title('Temp Title')
subtitle('Temp Subtitle')
axis([1 15 1e-4 .1])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Axes Appearance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!