Borrar filtros
Borrar filtros

Color in Scatter function

45 visualizaciones (últimos 30 días)
Sophie Leiter
Sophie Leiter el 13 de En. de 2021
Comentada: Sophie Leiter el 15 de En. de 2021
I am trying to plot 3 sets of data on the same scatter in 3 different colors but one of them doesn't have a letter code. I need one set unfilled black circles, one set filled grey circles, and one set filled black circles. Whenever I try to plot the grey though I get the error "There is no color property on the Scatter class". I've tried plotting with the plot function to get around this but I get a jumble of lines instead of dots. Does anyone know how to fix this? I've been working around it by selecting the points in the plotter and changing their color but that's tedious and annoying. I've including the code below. Thanks!
scatter(cp1,bd1, "k") % plot connected porosity vs bulkdensity of vdp1 set
hold on
scatter(cp2, bd2, 'color', [0.5 0.5 0.5], 'filled')
hold on
scatter(cp3, bd3, "k", 'filled')

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 13 de En. de 2021
Editada: Cris LaPierre el 13 de En. de 2021
There are two ways to specify the color - as the 4th input or with Name-Value pairs.
To use the 4th input, follow this example from the documentation
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
c = linspace(1,10,length(x));
scatter(x,y,[],[0.5 0.5 0.5],'filled')
Alternately, use the correct property name. Here is an example from the documentation.
theta = linspace(0,2*pi,300);
x = sin(theta) + 0.75*rand(1,300);
y = cos(theta) + 0.75*rand(1,300);
sz = 40;
scatter(x,y,sz,'MarkerEdgeColor',[0 .5 .5],...
'MarkerFaceColor',[0 .7 .7],...
'LineWidth',1.5)
  1 comentario
Sophie Leiter
Sophie Leiter el 15 de En. de 2021
This was helpful. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by