Plot a function with an specific colour asociated to each data

2 次查看(过去 30 天)
I want to plot irradiaction data vs the exposure time, but I also want to assign an specific colour (described with RGB or CIELab parameters) to each value of irradiance.
Is there any way to plot irradiance vs time and create a fit associated with the color creating a custom colorbar? or at least, a plot with changing colour (ΔE* ) vs the irradiance but with the associated colorbar?
In order to calculate ΔE*, my reference colour value is the fist one, with is zero exposure.
ΔE* = ( ( L*1-L*2)2 + (a*1-a*2)2+(b*1-b*2)2 )1/2
Below I show the code with the graphs that I want to obtain, where it would be necessary to add the line colour.
clear all
clc
%Data
A=[88.83 -7.90 49.88 0 0
81.19 5.46 34.44 10.4 5
78.86 8.68 33.31 14.7 10
75.71 13.76 24.59 25.5 20
72.87 18.72 20.56 35.1 32
71.00 21.25 17.31 50.1 50];
L=A(:,1); %L*
a=A(:,2); %a*
b=A(:,3); %a*
I=A(:,4); %irradiance in mJ/cm2
t=A(:,5); %time in s
%Figure 1
figure (1)
plot(t,I)
xlabel('t (s)')
ylabel('I (mJ/cm^2)')
%Colour difference
for i=1:6
DL_star=A(i,1)-A(1,1);
Da_star=A(i,2)-A(1,2);
Db_star=A(i,3)-A(1,3);
DE_star(i)=sqrt((DL_star)^2+(Da_star)^2+(Db_star)^2);
end
%Graph of colour difference vs irradiance
figure(2)
plot(I,DE_star)
xlabel('I (mJ/cm^2)')
ylabel('\DeltaE')

回答(1 个)

KSSV
KSSV 2022-12-22
x = linspace(0,2*pi)' ;
y = sin(x) ;
z = y ;
% Plot data:
surf([x x], [y y], [z z], 'FaceColor', 'none','EdgeColor', 'interp', 'LineWidth', 2);
view(2);
colormap(jet)
colorbar;
  3 个评论
KSSV
KSSV 2022-12-22
The RGB color bar represents the variation of y along the curve.
jet
ans = 256×3
0 0 0.5156 0 0 0.5312 0 0 0.5469 0 0 0.5625 0 0 0.5781 0 0 0.5938 0 0 0.6094 0 0 0.6250 0 0 0.6406 0 0 0.6562
Beatriz
Beatriz 2022-12-22
But in your graph, the color does not add information, it only highlights the change of y that is already seen in the plot.
What I want is to represent a variation of z with the colour, not y. But I dont know if it is possible to link data colour (the three RGB data values) with a single colour bar.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by