Azzera filtri
Azzera filtri

spy, making nodes more visible

6 visualizzazioni (ultimi 30 giorni)
Jan
Jan il 24 Set 2016
Commentato: Jan il 26 Set 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 Commenti
John D'Errico
John D'Errico il 24 Set 2016
Modificato: John D'Errico il 24 Set 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 il 26 Set 2016
OK, and what about this: How do I make nodes in "spy" that are closer then "d" connected via solid (OR dotted) line?

Accedi per commentare.

Risposta accettata

John D'Errico
John D'Errico il 24 Set 2016
Modificato: John D'Errico il 24 Set 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]

Più risposte (0)

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by