spy, making nodes more visible

14 vues (au cours des 30 derniers jours)
Jan
Jan le 24 Sep 2016
Commenté : Jan le 26 Sep 2016
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 commentaires
John D'Errico
John D'Errico le 24 Sep 2016
Modifié(e) : John D'Errico le 24 Sep 2016
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 le 26 Sep 2016
OK, and what about this: How do I make nodes in "spy" that are closer then "d" connected via solid (OR dotted) line?

Connectez-vous pour commenter.

Réponse acceptée

John D'Errico
John D'Errico le 24 Sep 2016
Modifié(e) : John D'Errico le 24 Sep 2016
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]

Plus de réponses (0)

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by