Filter löschen
Filter löschen

spy, making nodes more visible

6 Ansichten (letzte 30 Tage)
Jan
Jan am 24 Sep. 2016
Kommentiert: Jan am 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 Kommentare
John D'Errico
John D'Errico am 24 Sep. 2016
Bearbeitet: John D'Errico am 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 am 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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John D'Errico
John D'Errico am 24 Sep. 2016
Bearbeitet: John D'Errico am 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]

Weitere Antworten (0)

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by