How to brush data automatically?

On the "Figure Editor" window there is button "brush/select data". Also command >>brush exists. This effects in case: >>fplot('x^2',[0 1]), as noted in help on this command. But no effect (to remark part of graph by color) here: >>F=inline('x*cos(y)+2*y*cos(x)-1./(2*x+y)');ezplot(F)
Why?
And also question: For curve y(x) or r(t) (2 or 3D), how to remark (without marker, only color) a parts of curve by program way (without mouse)? For example, for parabola on abscissa [0;1]-red,[1;2]-orange,... but using one line-obiect, that is, parabola has already given as whole.

Antworten (2)

Sarah Wait Zaranek
Sarah Wait Zaranek am 25 Mai 2011

1 Stimme

Only certain plots can be brushed. The doc has list here of what you can and can't brush: http://www.mathworks.com/help/releases/R2011a/techdoc/ref/brush.html#brhzjsn
ezplot isn't explicitly listed in the can't brush list - but plots like it are listed.
In the second question, you are just turning the interactive brush functionality on by using the command brush. You aren't actually picking any points to be brushed.
If you want to actually set the brush data programatically, you need to go into the objects and set the data here.
hB = findobj(gcf,'-property','BrushData');
set(hB,'BrushData', YourNewValues')
By default if you have nothing highlighted, it will be a vector of all zeros. Brush Data has the same length as X (or Y) and is a vector of 1s or 0s (not logical, i think actually uint8) that has a 1 if you want that point brushed or a zero if you don't).
You can see what it looks like by doing the following:
get(hB,'BrushData');

5 Kommentare

Igor
Igor am 26 Mai 2011
More code, please...
for example, how to colorize initial part of parabola?
Sarah Wait Zaranek
Sarah Wait Zaranek am 26 Mai 2011
I think I miss understood what you wanted - I will alter my response shortly.
Igor
Igor am 26 Mai 2011
I think you understood rightly :)
To replace the mouse clicks on rectangle corners by programmable way
Igor
Igor am 26 Mai 2011
What is 'BrushData'? pairs of (X,Y) extracted from (Xdata,Ydata)? or four values of rectangle?
Sarah Wait Zaranek
Sarah Wait Zaranek am 26 Mai 2011
Brush Data has the same length as X (or Y) and is a vector of 1s or 0s (not logical, i think actually uint8) that has a 1 if you want that point brushed or a zero if you don't). You can see what it looks like by doing the following:
get(hB,'BrushData');

Melden Sie sich an, um zu kommentieren.

Igor
Igor am 2 Jun. 2011

0 Stimmen

x=1:0.5:10;y=x.^2;hf=figure(1);plot(x,y);
hb=brush(hf);get(hb);set(hb,'Color',[0 1 0]);
To define brush data I need mouse but I wish set the range automatically (wit hout mouse).
>> get(hb)
ButtonDownFilter: @localButtonDownFilter
ActionPreCallback: []
ActionPostCallback: []
Enable: 'on'
FigureHandle: [1x1 figure]
Color: [0 1 0]
>> get(hb,'BrushData')
??? There is no 'BrushData' property in the 'brush' class.

3 Kommentare

Sarah Wait Zaranek
Sarah Wait Zaranek am 2 Jun. 2011
Use this instead ---
hB = findobj(gcf,'-property','BrushData');
set(hB,'BrushData', YourNewValues')
Igor
Igor am 2 Jun. 2011
It's interesting that Figure Inspector don't show this Property for the Line although hB (by command get) shows type "line".
I shell try to improve code

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics Object Properties finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 25 Mai 2011

Bearbeitet:

am 14 Nov. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by