Change all Plot MarkerSizes at once?

12 visualizaciones (últimos 30 días)
Felicia Brimigion
Felicia Brimigion el 6 de En. de 2021
Comentada: Felicia Brimigion el 7 de En. de 2021
I have about 7 subplots, each with four plots)
Each plot has 8-16 separate plots, I was wondering if there is any way to make a blanket statement of sorts, to change the markersize of each point to 10, without having to do ,'MarkerSize',10 after every single (x,y) and (a,b) pair:
plot([x([2:4],:),y([2:4],:),'.',x([5:8],:),y([5:8],:),'.',x([9:11],:),y([9:11],:),'.', ...
a([2:4],:),b([2:4],:),'.',a([5:8],:),b([5:8],:),'.',a([9:11],:),b([9:11],:),'.')
These need to be indexed separately like this for unrelated legend reasons. This type of plotting occurs for every single plot, in each subplotso it would be quite tedious to have to copy/paste:
,'MarkerSize',10
after every single pair for every plot for every subplot.
Thank you!

Respuestas (1)

Steven Lord
Steven Lord el 6 de En. de 2021
x = 0:360;
h = gobjects(1, 5);
ax = axes;
axis([0 360 -1 1]);
hold on
for k = 1:5
h(k) = plot(x, sind(k*x), 'o-', 'MarkerIndices', 1:6*k:361, 'UserData', k);
end
Now let's find all the objects in the axes that have a MarkerSize property.
h2 = findall(ax, '-property', 'MarkerSize');
Now change them.
for whichone = 1:numel(h2)
this = h2(whichone);
oldMS = this.MarkerSize;
newMS = oldMS*this.UserData;
this.MarkerSize = newMS;
end
I used a for loop because I wanted to give each line a different MarkerSize. If you wanted to change them all to the same value, use set. Since I previously changed the MarkerSize property, here I'll change LineStyle instead.
set(h2, 'LineStyle', '--')
  2 comentarios
Stephen23
Stephen23 el 6 de En. de 2021
Oooh, I like that. TMW should release a line of MATLAB-branded gift-wrapping paper. Or wallpaper.
Felicia Brimigion
Felicia Brimigion el 7 de En. de 2021
Thank you so much! I will give that a try!!

Iniciar sesión para comentar.

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by