O'Reilly logo

MATLAB Graphics and Data Visualization Cookbook by Swapnonil Banerjee, Nivedita Majumdar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using annotations pinned to the axes

MATLAB provides an interface to place custom elements on the graphics using the command annotation. Lines, arrows, double-ended arrows, text arrows, textboxes, ellipses, and rectangles are all valid elements you can overlay on your basic graphic to convey information.

Getting ready

In this recipe, you will plot the standard normal distribution and add a text arrow to point out the location of the mean value on the graphic.

load stdNormalDistribution;

How to do it...

Perform the following steps:

  1. Plot the data. Add the line at the mean position:
    plot(x,y1);
    line([mean1 mean1],get(gca,'ylim'));
  2. Add the text arrow annotation component by first converting the desired location for the arrow from data space coordinates to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required