How to scatter plot using different colors by using own RGB data?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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)
0 comentarios
Respuestas (2)
Cris LaPierre
el 10 de Nov. de 2021
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');
Image Analyst
el 11 de Nov. de 2021
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)
2 comentarios
Image Analyst
el 16 de Dic. de 2021
I'm not sure I understand the problem. Can you upload your files?
Ver también
Categorías
Más información sobre Graphics Performance 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!