spy, making nodes more visible

6 次查看(过去 30 天)
How do I modify the Matlab command spy to have more visible (red) nodes of graphs? Say something like this THIS on page 7.
  3 个评论
John D'Errico
John D'Errico 2016-9-24
编辑:John D'Errico 2016-9-24
Um, I suppose that is a valid question. Is it not obvious? :) Ok, maybe not completely so.
The trick is to recognize that when you do a spy plot, you created a set of axes. The handle to those axes is given by gca (the current set of axes that are up front.)
So if you do
get(gca)
you will see lots of things. One of them is 'children'. What you actually plotted are children of those axes. So
get(gca,'children')
gives a handle to what is in the plot. In this case, it is only one thing, a set of dots as line, created by spy.
get(gca,'children')
ans =
Line with properties:
Color: [0 0 1]
LineStyle: 'none'
LineWidth: 0.5
Marker: '.'
MarkerSize: 50
MarkerFaceColor: 'none'
XData: [1 1 3 4 6 6 8 8 8 10]
YData: [4 9 4 7 5 6 2 3 6 10]
ZData: [1x0 double]
So now you can control the properties of that plot. You can change the markersize. You can change the color of the dots, both of which I did.
Obvious? I suppose it is not, depending on your programming background. But not that hard once you start to learn about handle graphics in MATLAB. You could start reading under 'Graphics Objects' in the docs.
Jan
Jan 2016-9-26
OK, and what about this: How do I make nodes in "spy" that are closer then "d" connected via solid (OR dotted) line?

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2016-9-24
编辑:John D'Errico 2016-9-24
spy(sprand(10,10,.1))
set(get(gca,'children'),'markersize',50,'color','r')
get(gca,'children')
ans =
Line with properties:
Color: [0 0 1]
LineStyle: 'none'
LineWidth: 0.5
Marker: '.'
MarkerSize: 50
MarkerFaceColor: 'none'
XData: [1 1 3 4 6 6 8 8 8 10]
YData: [4 9 4 7 5 6 2 3 6 10]
ZData: [1x0 double]

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by