File Exchange

image thumbnail

draw

version 1.0.0.0 (5.34 KB) by Chad Greene
Easily draw shapes on a figure via mouse.

4 Downloads

Updated 22 Sep 2015

View License

This function lets you easily draw shapes on a current figure. The image above was created by

draw 'arrow'
draw('ellipse','facecolor','r','color','b','linewidth',3)
draw('rectangle','linewidth',1.5,'color',[0.08 0.69 0.10])
draw('doublearrow','linewidth',3,'headstyle','rose','color',[0.98 0.45 0.24])

After calling draw, you may:

* Click and drag to draw shapes,

* press 'a', 'e', 'l', 'r', or 'd' on your keyboard to change the shape to arrow, ellipse, line, rectangle, or doublearrow,

* press backspace to delete previous shape,

* press escape to delete all shapes and quit drawing mode, or

* press enter to keep shapes as they appear in the figure.

Comments and Ratings (3)

Sorry -- ignore that part about " 'Name', 'Drawing Mode On...' " . Drawing stuff not in the `annotations` list would require markedly different code.

Very nice indeed. Code is clean, so easy to see how one might add other "set(gcf,'Name','Drawing Mode On: Some_other_shape')".
Feature request: set a bunch of keypresses to change the line color dynamically.

Brad

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux