1 / 70

Motivation The interactive tools: Drawing commands Interactive figure manipulation

Motivation The interactive tools: Drawing commands Interactive figure manipulation The programmer point of view: Introduction to objects and their handles Invoking and manipulating graphics objects. The interactive tools. >> x = -5:0.05:5; % [-5 -4.95 …….4.95 5] >> y = sin(x.^2) ;

tricia
Télécharger la présentation

Motivation The interactive tools: Drawing commands Interactive figure manipulation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Motivation • The interactive tools: • Drawing commands • Interactive figure manipulation • The programmer point of view: • Introduction to objects and their handles • Invoking and manipulating graphics objects

  2. The interactive tools >> x = -5:0.05:5; % [-5 -4.95 …….4.95 5] >> y = sin(x.^2); >> plot(x,y)

  3. none

  4. The axes is contained within the figure. • A figure may have more than one axes.

  5. The plot is contained within the axes. • An axes may have more than one plot.

  6. >> y2= 1./(1+exp(-x)); >> hold Current plot held >> plot(x,y2,'color','k','lineStyle','-.')

  7. >> y2= 1./(1+exp(-x)); >> hold Current plot held >> plot(x,y2,'color','k','lineStyle','-.') Property-name, property value pair

  8. >> y2= 1./(1+exp(-x)); >> hold Current plot held >> plot(x,y2,'color','k','lineStyle','-.') Property-name, property value pair

  9. Specifier Line Style Specifier Marker type - solid line (default) + Plus sign o circle -- dashed line * asterisk : dotted line . point -. dash-dot line x cross s square Specifier Color d diamond ^ triangle pointing upward r Red v triangle pointing downward g green > triangle pointing right b blue < triangle pointing left c cyan p five-pointed star (pentagram) m magenta h six-pointed star (hexagram) y yellow k black w white

  10. Alternative format: >> x=[1 2.3 4 10 3 11.3]; >> y=[3.2 5 2 7.4 3 9.4]; >> p2=plot(x,y,'or:’);

  11. Alternative format: >> x=[1 2.3 4 10 3 11.3]; >> y=[3.2 5 2 7.4 3 9.4]; >> p2=plot(x,y,'or:’); Marker ColorLineStyle • Use MATLAB help. • Consult the property inspector. There are more alternative formats

  12. Specialized 2D plots • Bars • Histograpms • Stair • Stem • Scatter • Error bars • Area • Pie charts • contour

  13. Use MATLAB help and demos. Specialized 3D plots • plot3 • mesh • surf

  14. The programmer’s point of view: • Graphic Objects • Handles • Properties

  15. Graphic Object (figure, axes, text, line etc.) handle

  16. Graphic Object (figure, axes, text, line etc.) handle properties

  17. Many objects may exist simultaneously

  18. We use the handles to pick an object and manipulate it.

  19. An object may have more than one handle

  20. Objects may contain other objects

  21. Graphic object: any element as defined by the set of its properties that constitute part of a figure • Everything inside a figure window is a graphic object • The figure window itself is a graphic object • All plots in MATLAB are made of graphic objects • All graphic objects have properties that control the way they look and behave

  22. >> t = -pi:0.05:pi; >> x = cos(3*t)*1./(1+exp(-t)); >> y = sin(3*t)*1./(1+exp(-t)); >> p = plot(x,y) p = 158.0055 A handle

  23. Objects • The plot • The axes • The figure • ? • Handles • p is the plots handle • ? • ?

  24. >>set(p,'color','r') >>set(p,'lineWidth',4) handle

  25. >>set(p,'color','r') >>set(p,'lineWidth',4) property names

  26. >>set(p,'color','r') >>set(p,'lineWidth',4) property values How would I know what properties does the plot have?

  27. >> get(p) Color: [1 0 0] EraseMode: 'normal' LineStyle: '-' LineWidth: 4 Marker: 'none' MarkerSize: 6 MarkerEdgeColor: 'auto' MarkerFaceColor: 'none' XData: [1x126 double] YData: [1x126 double] ZData: [1x0 double] BeingDeleted: 'off' ButtonDownFcn: [] Children: [0x1 double] Clipping: 'on' CreateFcn: [] DeleteFcn: [] BusyAction: 'queue' HandleVisibility: 'on' HitTest: 'on' Interruptible: 'on' Selected: 'off' SelectionHighlight: 'on' Tag: '' Type: 'line' UIContextMenu: [] UserData: [] Visible: 'on' Parent: 157.0059 DisplayName: '' XDataMode: 'manual' XDataSource: '' YDataSource: '' ZDataSource: ''

  28. handle >> p_parent=get(p,'parent') p_parent = 157.0059

  29. property name >> p_parent=get(p,'parent') p_parent = 157.0059

  30. property value >> p_parent=get(p,'parent') p_parent = 157.0059

  31. >> p_parent=get(p,'parent') p_parent = 157.0059 p_parent is a handle. Of what? >> get(p_parent,'type') ans = axes

  32. >> get(p_parent,'children') ??? ans = 158.0063 >> p ans = 158.0063

  33. >> set(p_parent,'xcolor','b'); >> set(p_parent,'ycolor','b'); What about the title? >> title=get(p_parent,'title') title = 163.0059 >> get(title,'type') ans = text

  34. >> set(p_parent,'xcolor','b'); >> set(p_parent,'ycolor','b'); What about the title? >> title=get(p_parent,'title') title = 163.0059 >> get(title,'type') ans = text >> set(title,'string','Spiral') >> set(title,'color','b')

  35. Lets add another line >> x1 = -cos(3*t)*1./(1+exp(-t)); >> y1 = -sin(3*t)*1./(1+exp(-t)); >> plot(x1,y1) Ooooops… >> lines = get(p_parent,'children') lines = 204.0061 158.0063 >> blue=lines(1) blue = 204.0061 >> set(blue,'lineWidth',4)

  36. Alternatively: >> findobj('color','b') ans = 204.0061

  37. Who is the title’s parent? Who are the title’s children? Who is the axes` parent? Who is the figure’ parent?

  38. Graph Objects Phylogeny • This hierarchy is based on the interdependency of objects. A line can only be plotted inside an Axes. A figure contains Axes and so on.

  39. Graph Objects Phylogeny parent

  40. Graph Objects Phylogeny children

  41. …in the beginning there is only the root object…. • Hello, I am the root object • Although I am the root I always got a 0 as my handle • I know and control many important things… Type get(0) to see all my properties

  42. What is the difference between a handle and “simple variable”? >> get(title,'String') ans = Spiral >> ttt = title; >> set(ttt,'string','Red wide spiral') >> get(title,'String') ans = Red wide spiral >> a = [1 2 3 4 5]; >> b = a; >> b(3)=9 b = 1 2 9 4 5 >> a a = 1 2 3 4 5

  43. handle right_handle = handle

More Related