Various marker sizes in a single plot

9 ビュー (過去 30 日間)
Aaron Mears
Aaron Mears 2015 年 11 月 15 日
コメント済み: Aaron Mears 2015 年 11 月 15 日
I am working on an assignment that requires that I create a solar system animation of three planets and a sun. So far I have all 3 planets and the sun, the planets are orbiting the sun. However, I want the sun to be a different marker size than the planets and I can't seem to get it to work. I was under the impression that you were able to specify individual sizes, colors, etc...for each variable set. I have changed the colors successfully, but not the size. Here is the loop I am running for this animation:
for j = 1:length(x)
pause(0.05)
plot(0,0,'r.',x(j),y(j),'b.',a(j),b(j),'g.',c(j),d(j),'y.','markersize',20)
axis([minx maxx miny maxy]);
end
The first item in that plot set is the sun. I have just set it to 0,0 and colored it red. I've tried adding a marker size to it individually like this:
plot(0,0,'r.','markersize', 60,x(j),y(j),'b.',a(j),b(j),'g.',c(j),d(j),'y.','markersize',20)
However, with this I get the error "invalid first data argument" I am not sure why because as I've read that this should be able to be done this way. I've also tried giving every single variable set their own, with the same error.

採用された回答

Walter Roberson
Walter Roberson 2015 年 11 月 15 日
Only the last Name/Value specification is paid attention to for any one named option used in a plot() call. This is not the case for "linespec" specifications given without a parameter name (such as 'r-o' for sold red lines with red circle markers).
To set multiple marker sizes you need to assign the output of the plot call to a variable and set() the appropriate handle
h = plot(0,0,'r.',x(j),y(j),'b.',a(j),b(j),'g.',c(j),d(j),'y.','markersize',20)
set(h(1), 'markersize', 60)
  1 件のコメント
Aaron Mears
Aaron Mears 2015 年 11 月 15 日
Thank you very much, that worked perfectly. I'm not sure why I couldn't find this before. Everything else I've read seemed to list that I could do it the way I was trying to do it. Thanks again.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEarth and Planetary Science についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by