Change all Plot MarkerSizes at once?
12 ビュー (過去 30 日間)
古いコメントを表示
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!
0 件のコメント
回答 (1 件)
Steven Lord
2021 年 1 月 6 日
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 件のコメント
Stephen23
2021 年 1 月 6 日
Oooh, I like that. TMW should release a line of MATLAB-branded gift-wrapping paper. Or wallpaper.
参考
カテゴリ
Help Center および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!