scatterCreate
xas 200 equally spaced values between 0 and 3π. Createyas cosine values with random noise. Then, create a scatter plot.
x = linspace(0,3*pi,200); y = cos(x) + rand(1,200); scatter(x,y) fig2plotly()
Create a scatter plot using circles with different sizes. Specify the size in points squared
x = linspace(0,3*pi,200); y = cos(x) + rand(1,200); sz = linspace(1,100,200); scatter(x,y,sz) fig2plotly()
Corresponding elements in
x,y, andszdetermine the location and size of each circle. To plot all circles with the equal area, specifyszas a numeric scalar.
Create a scatter plot and vary the circle color.
x = linspace(0,3*pi,200); y = cos(x) + rand(1,200); c = linspace(1,10,length(x)); scatter(x,y,[],c) fig2plotly()
Corresponding elements in
x,y, andcdetermine the location and color of each circle. Thescatterfunction maps the elements incto colors in the current colormap.
Create a scatter plot and fill in the markers.
scatterfills each marker using the color of the marker edge.
x = linspace(0,3*pi,200); y = cos(x) + rand(1,200); sz = 25; c = linspace(1,10,length(x)); scatter(x,y,sz,c,'filled') fig2plotly()
Create vectors
xandyas sine and cosine values with random noise. Then, create a scatter plot and use diamond markers with an area of 140 points squared.
theta = linspace(0,2*pi,150); x = sin(theta) + 0.75*rand(1,150); y = cos(theta) + 0.75*rand(1,150); sz = 140; scatter(x,y,sz,'d') fig2plotly()
Create vectors
xandyas sine and cosine values with random noise. Create a scatter plot and set the marker edge color, marker face color, and line width.
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)
fig2plotly()
You can vary the transparency of scattered points by setting the
AlphaDataproperty to a vector of different opacity values. To ensure the scatter plot uses theAlphaDatavalues, set theMarkerFaceAlphaproperty to'flat'.Create a set of normally distributed random numbers. Then create a scatter plot of the data with filled markers.
x = randn(1000,1); y = randn(1000,1); s = scatter(x,y,'filled'); fig2plotly()
Set the opacity of each point according to its distance from zero.
distfromzero = sqrt(x.^2 + y.^2); s.AlphaData = distfromzero; s.MarkerFaceAlpha = 'flat'; fig2plotly()
Starting in R2019b, you can display a tiling of plots using the
tiledlayoutandnexttilefunctions. Call thetiledlayoutfunction to create a 2-by-1 tiled chart layout. Call thenexttilefunction to create the axes objectsax1andax2. Plot scattered data into each axes. In the bottom scatter plot, specify diamond filled diamond markers.
x = linspace(0,3*pi,200); y = cos(x) + rand(1,200); tiledlayout(2,1) % Top plot ax1 = nexttile; scatter(ax1,x,y) % Bottom plot ax2 = nexttile; scatter(ax2,x,y,'filled','d') fig2plotly()
Create a scatter plot and return the scatter series object,
s.
theta = linspace(0,1,500); x = exp(theta).*sin(100*theta); y = exp(theta).*cos(100*theta); s = scatter(x,y); fig2plotly()
Use
sto query and set properties of the scatter series after it has been created. Set the line width to0.6point. Set the marker edge color to blue. Set the marker face color using an RGB triplet color.
s.LineWidth = 0.6; s.MarkerEdgeColor = 'b'; s.MarkerFaceColor = [0 0.5 0.5]; fig2plotly()