Various marker sizes in a single plot

11 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Earth and Planetary Science 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by