how can i plot a horozontal bar graph where the bars color change acording to a formula?
i have 5 different hights (70, 115, 164, 216, 270) each going from 0 to 130 that change intensity acording to different formula for each hight
i want to draw a horozontal bar graph with hights on y axes 0-130 on y axes and the bar changing colors accoring to the formulas

댓글 수: 10

Mehmed Saad
Mehmed Saad 2020년 4월 16일
can you give me the formula from which you want to change the color
ralph glastonbury
ralph glastonbury 2020년 4월 16일
Y = 0,000000272010410X^3 - 0,000071941838974X^2 + 0,004930888800712X + 1,902355241509030
it should look like a color map but change colors according to this formula
Mehmed Saad
Mehmed Saad 2020년 4월 16일
something like this
or this
ralph glastonbury
ralph glastonbury 2020년 4월 16일
yes but the color should change acording to the formula
Mehmed Saad
Mehmed Saad 2020년 4월 16일
편집: Mehmed Saad 2020년 4월 16일
yup but i didn't get your formula
colors are in the format of [r g b], how can you get these 3 values from your formula?
Y = 0,000000272010410X^3 - 0,000071941838974X^2 + 0,004930888800712X + 1,902355241509030
ralph glastonbury
ralph glastonbury 2020년 4월 16일
i want something like a color map where the color change as y change
like the botom graph you send. the y axis stays at 1 but the colors in the bar changes acording to the formula
Y = 0,000000272010410X^3 - 0,000071941838974X^2 + 0,004930888800712X + 1,902355241509030
Mehmed Saad
Mehmed Saad 2020년 4월 16일
color has three components [R,G,B], the formula should be such that it calculates the value of all three components for example
R = 0.15*X^2+0.12786*X^3+1.956;
G = 0.75*X^2+0.52786*X^3+0.956;
B = 0.95*X^2+0.72786*X^3+3.956;
Now that is what i want
ralph glastonbury
ralph glastonbury 2020년 4월 16일
Sorry i think i miscommunicated
The formula is a trend line for some data I have
I want to show how the data changes for x from 0 to 130
For that numbers y changes from about 1.9 to about 2.01
So for example if x=0, y would be about 1.9 it should show blue on the bar
And if x=130 y would be less than 2.01 and that should show red
Like on the jet colormap
So the color would change as x change
Does this make sense?
Mehmed Saad
Mehmed Saad 2020년 4월 16일
편집: Mehmed Saad 2020년 4월 16일
is this right? i am only change R and B values not G
ralph glastonbury
ralph glastonbury 2020년 4월 16일
yes that is what im looking for

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

 채택된 답변

Mehmed Saad
Mehmed Saad 2020년 4월 14일
편집: Mehmed Saad 2020년 4월 16일

0 개 추천

Now i am giving you code for only generating 1 peak which is random, you ve to generate the remaining by yourself
figure,
h=barh([0 1],[zeros(1,131);randi(3,1,131)],'stacked','BarWidth',0.4);
X = 0:130;
Y = 0.000000272010410*X.^3 - 0.000071941838974*X.^2 + 0.004930888800712*X + 1.902355241509030;
Z=Y-min(Y);
Z=Z/max(Z);
for i=1:131
h(i).FaceColor = [1-Z(i) 0 Z(i)];%m(i,:);
h(i).EdgeColor = [1-Z(i) 0 Z(i)];%m(i,:);
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by