How to change color of berfit curve
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Melody
el 23 de Mayo de 2024
Respondida: Les Beckham
el 23 de Mayo de 2024
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 comentarios
Respuesta aceptada
Voss
el 23 de Mayo de 2024
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 comentarios
Más respuestas (1)
Les Beckham
el 23 de Mayo de 2024
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 comentarios
Ver también
Categorías
Más información sobre Axes Appearance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!