フィルターのクリア

App With Bar Graph

8 ビュー (過去 30 日間)
kileigh palmer
kileigh palmer 2021 年 3 月 12 日
回答済み: Monisha Nalluru 2021 年 3 月 16 日
Hello! I can manage to get my data values to plot correctly on the app, but I just want to change to color of the bars. This is the script I tried running with the color change, where I tried using the Cdata to get different colored bars. Any help is appreciated!!
function UIAxesButtonDown(app, event)
bf = app.BodyFatEditField.Value;
Dmax = app.DiameterMaxEditField.Value;
Dmin = app.DiameterMinEditField.Value;
Psys = app.SystolicPressureEditField.Value*0.0013;
Pdia = app.DiastolicPressureEditField.Value*0.0013;
Pdrop = Psys-Pdia;
Ddrop = Dmax-Dmin;
EM = (Pdrop*Dmax)/Ddrop;
patients = [1 2 3 4 5];
bodyfat = .10;
bodyfatc = .22;
bodyfatl = .42;
bodyfath = .67;
EMc = 0.4025;
EMh = 0.3248;
EMk = 0.3177;
EMl = 0.488;
bf = [bodyfat bodyfath bodyfatc bodyfatl app.BodyFatEditField.Value; EMk EMh EMc EMl EM];
bar(app.UIAxes, patients,bf, 'FaceColor', 'flat')
b.Cdata = [0 .5 .5; .5 0 .8];

回答 (1 件)

Monisha Nalluru
Monisha Nalluru 2021 年 3 月 16 日
From my understanding, you want to add color to bars in bar plot.
This can be achieved using CData in with bar plot function
Refer to the following documentation:
As an example
function ButtonPushed(app, event)
y = [1 3 5; 3 2 7];
b = bar(y,'Parent',app.UIAxes,"FaceColor",'flat');
b(1).CData = [0 .5 .5];
b(2).CData = [.5 0 .8];
end

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by