필터 지우기
필터 지우기

How to scatter plot using different colors by using own RGB data?

조회 수: 6 (최근 30일)
義典 鈴木
義典 鈴木 2021년 11월 9일
댓글: Image Analyst 2021년 12월 16일
I`m using Matlab App Designer to create a scatter plot and I want to use my own rgb data for the colors but I think my code is wrong somewhere.
Style = app.SelectedStyles;
Colors = app.SelectedColors;
% Start with a fresh plot
cla(app.UIAxes)
hold(app.UIAxes,'on')
% Select relevant segment of data
xdata = app.Data.a;
ydata = app.Data.b;
cdata = app.Data.c;
%cdata = app.Data.c;
% Filter the data according to the controls
filterData(app);
% Build a scatter plot for each selected style
for ii = 1:length(Style)
selectedstyles = ((app.Data.styles == Style(ii)) & (app.displayedIndices));
selectedcolors = ((app.Data.c == Colors(ii)) & (app.displayedIndices));
scatter(app.UIAxes,xdata((selectedstyles)),ydata(selectedstyles),cdata(selectedcolors),'filled','s');
end
annotateScatterPlot(app)
% Update the table to show only the data that satisfies the controls
app.UITable.Data = app.Data(app.displayedIndices,:);
drawnow;
% List which styles and colors to use
Style = [];
Colors = [];
if app.JapaneseCheckBox.Value
Style = "japanese";
Colors = [];
end
if app.AfricanCheckBox.Value
Style = [Style "African"];
Colors = [];
end
app.SelectedStyles = Style;
app.SelectedColors = Colors;
refreshplot(app)

답변 (2개)

Cris LaPierre
Cris LaPierre 2021년 11월 10일
Color is the 4th input to scatter.
You have placed it in the 3rd spot, which is for size. What happens if you try this?
scatter(app.UIAxes,xdata((selectedstyles)),ydata(selectedstyles),[],cdata(selectedcolors),'filled','s');
  댓글 수: 1
義典 鈴木
義典 鈴木 2021년 12월 16일
Thank you for the reply. I already tried this but nothing changes. I guess there is something wrong in the code I wrote in the app

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


Image Analyst
Image Analyst 2021년 11월 11일
If you use the built-in colorcloud() function, does that do what you want? (Ignore the red junk after the image).
img = imread('peppers.png');
colorcloud(img)
Error using uicontrol
This functionality is not available on remote platforms.

Error in rotate3d>localCreateAzElIndicator (line 478)
rdata.ModeStateData.textBoxText = uicontrol('Parent',hFig,'Units','Pixels',...

Error in rotate3d>localDoRotateOn (line 508)
localCreateAzElIndicator(rdata)

Error in rotate3d>@(~,~)localDoRotateOn(rdata) (line 393)
set(rdata,'ModeStartFcn',@(~,~)localDoRotateOn(rdata));

Error in hgfeval (line 62)
feval(fcn{1},varargin{:},fcn{2:end});

Error in matlab.uitools.internal.uimode/modeControl (line 16)
hgfeval(hThis.ModeStartFcn);

Error in matlab.uitools.internal.uimode/set.Enable (line 167)
obj.Enable = modeControl(obj,value);

Error in matlab.uitools.internal.uimodemanager>localSetMode (line 200)
set(newMode,'Enable','on');

Error in matlab.uitools.internal.uimodemanager/set.CurrentMode (line 119)
obj.CurrentMode = localSetMode(obj,value);

Error in activateuimode (line 30)
set(hManager,'CurrentMode',hMode);

Error in rotate3d>setState (line 363)
activateuimode(fig,'Exploration.Rotate3d');

Error in rotate3d (line 262)
setState(hTarget,arg2,rotatestyle)

Error in colorcloud>setAxesProperties (line 205)
rotate3d(hAx,'on');

Error in colorcloud (line 121)
setAxesProperties(hPanel,hAx,options);
  댓글 수: 2
義典 鈴木
義典 鈴木 2021년 12월 16일
Thank you. I am actually doing color analysis and I want to plot the main color in the a-b graph. I want to plot the coordinates with the color responding to the analysis. For example,
a =[2,3,6,3,6,9]
b =[1,5,6,7,5,4]
c =[0.1 0.4 0.5
0.4 0.6 0.8
0.5 0.8 0.2
0.3 0.1 0.6
0.7 0.8 0.9
0.5 0.3 0.3
]
but the problem is I am using app designer and I use mat file to store the data
Image Analyst
Image Analyst 2021년 12월 16일
I'm not sure I understand the problem. Can you upload your files?

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by