Add subtitle to plot - MATLAB subtitle (2024)

Add subtitle to plot

Since R2020b

collapse all in page

    Syntax

    subtitle(txt)

    subtitle(___,Name,Value)

    subtitle(target,___)

    t = subtitle(___)

    Description

    example

    subtitle(txt) adds the specified subtitle text to the current axes.

    example

    subtitle(___,Name,Value) sets properties on the text object using one or more name-value pair arguments. Specify the properties after all other input arguments. For a list of properties, see Text Properties.

    example

    subtitle(target,___) specifies the target object for the subtitle. The target object can be any type of axes, a tiled chart layout, or an array of objects. Specify the target object before all other input arguments.

    example

    t = subtitle(___) returns the text object for the subtitle. Use t to set properties on the object after creating the subtitle. For a list of properties, see Text Properties.

    Examples

    collapse all

    Add Subtitle

    Open Live Script

    Create a plot. Add a title with the title function. Then add a subtitle with the subtitle function.

    plot([0 2],[1 5])title('Straight Line')subtitle('Slope = 2, y-Intercept = 1')

    Add subtitle to plot - MATLAB subtitle (1)

    Include Variable in Subtitle

    Open Live Script

    Create a plot, and add a title to the plot. Define slopevalue and yintercept as numeric variables. Define txt as a combination of literal text and the values of slopevalue and yintercept converted to character vectors. Then, pass txt to the subtitle function to display the subtitle.

    plot([0 2],[1 5])title('Straight Line')slopevalue = 4;yintercept = 1;txt = ['Slope = ' int2str(slopevalue) ', y-Intercept = ' int2str(yintercept)];subtitle(txt)

    Add subtitle to plot - MATLAB subtitle (2)

    Change the Subtitle Color

    Create a plot. Add a title with the title function. Then, call the subtitle function, and specify the color using the 'Color' name-value pair argument. The color can be a color name, such as 'red', or you can specify a custom color using an RGB triplet or hexadecimal color code. In this case, specify 'red'.

    plot([0 2],[1 5])title('Straight Line')subtitle('Slope = 2, y-Intercept = 1','Color','red')

    Add subtitle to plot - MATLAB subtitle (3)

    Alternatively, call the subtitle function with an output argument to return the text object. Then set the color on the text object. In this case, specify the hexadecimal color code '#DD5500'.

    txt = subtitle('Plot of y = 2x + 1');txt.Color = '#DD5500';

    Add subtitle to plot - MATLAB subtitle (4)

    Create Multicolored Subtitle Using TeX Markup

    Open Live Script

    Create a plot, and add a title with the title function. Create a character vector containing TeX markup with custom colors for different words in the subtitle. Then pass the character vector to the subtitle function.

    plot([0 2],[1 5])title('Straight Line')txt = ['An {\color{magenta}Attractive '...'\color[rgb]{0 .5 .5}and \color{red}Colorful} Subtitle'];subtitle(txt)

    Add subtitle to plot - MATLAB subtitle (5)

    Include Greek Symbols

    Open Live Script

    Create a histogram, and add a title with the title function. Create a character vector containing TeX markup with Greek symbols. Then pass the character vector to the subtitle function.

    histogram(5*randn(1,50)+10)title('Population Data')txt = '{\it\mu} = 10, {\it\sigma} = 5';subtitle(txt)

    Add subtitle to plot - MATLAB subtitle (6)

    Include Superscripts and Subscripts

    Open Live Script

    Create a histogram, and add a title with the title function. Create a character vector containing TeX markup that displays subscripts and superscripts. Then pass the character vector to the subtitle function.

    x = -10:0.1:10;y1 = x.^2;y2 = 2*x.^2;plot(x,y1,x,y2);title('Exponential Functions')txt = 'y_1 = x^2 and y_2 = 2x^{2 + k}';subtitle(txt)

    Add subtitle to plot - MATLAB subtitle (7)

    To display an italic font for the variables, add the \it modifier.

    txt = '{\ity}_1 = {\itx}^2 and {\ity}_2 = 2{\itx}^{2 + \itk}';subtitle(txt)

    Add subtitle to plot - MATLAB subtitle (8)

    Create Multiline Subtitle

    Create a plot, and add a title with the title function. Then create a subtitle containing two lines of text by passing a cell array of character vectors to the subtitle function. Each element in the array is a separate line of text.

    plot([0 2],[1 5])title('Straight Line')txt = {'Slope = 2','y-Intercept = 1'};subtitle(txt)

    Add subtitle to plot - MATLAB subtitle (9)

    Display TeX Characters as Typed

    Open Live Script

    Create a plot with a title. Then create a subtitle containing an underscore character that the TeX interpreter normally uses for subscripts. Set the Interpreter to 'none' when you call the subtitle function, so that the underscore character appears in the subtitle.

    plot([0 2],[1 5])title('Straight Line')subtitle('y_1 = 2x + 1','Interpreter','none')

    Add subtitle to plot - MATLAB subtitle (10)

    Change Alignment of Title and Subtitle

    Open Live Script

    Create a plot and add a title and a subtitle. Get the current axes, and align the title and subtitle to the left edge of the plot box by setting the TitleHorizontalAlignment property on the axes to 'left'.

    plot([0 2],[1 5])title('Straight Line')subtitle('Slope = 2, y-Intercept = 1')ax = gca;ax.TitleHorizontalAlignment = 'left';

    Add subtitle to plot - MATLAB subtitle (11)

    Center the title and subtitle by setting the TitleHorizontalAlignment property on the axes to 'center'.

    ax.TitleHorizontalAlignment = 'center';

    Add subtitle to plot - MATLAB subtitle (12)

    Specify Target Axes

    Open Live Script

    Create two plots in a tiled chart layout. Then add a title and subtitle to each plot.

    t = tiledlayout(1,2);% Left plotax1 = nexttile;plot([0 2],[1 5])title(ax1,'A Straight Line')subtitle(ax1,'Slope = 2, y-Intercept = 1')% Right plotax2 = nexttile;plot([0 2],[2 8])title(ax2,'Another Straight Line')subtitle(ax2,'Slope = 3, y-Intercept = 2')

    Add subtitle to plot - MATLAB subtitle (13)

    Input Arguments

    collapse all

    txtSubtitle text
    character vector | cell array of character vectors | string array

    Subtitle text, specified as a character vector, cell array of character vectors, or a string array. To create multiple lines of text, specify a cell array of character vectors or a string array.

    Example: subtitle('Single Line Subtitle')

    Example: subtitle(["Subtitle With" "Multiple Lines"])

    targetTarget for the subtitle
    axes | tiled chart layout | array of objects

    Target for the subtitle, specified as one of the following:

    • Any type of axes: an Axes, PolarAxes, or GeographicAxes object.

    • A TiledChartLayout object.

    • An array of graphics objects from the preceding list. The objects must belong to the same class. To determine the class, use the class function.

    If you do not specify the target for the subtitle, then the subtitle function adds the subtitle to the graphics object returned by the gca command.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: subtitle('My Subtitle','FontSize',12) specifies a 12-point font size.

    Note

    The properties listed here are only a subset. For a complete list, see Text Properties.

    FontSizeFont size
    11 (default) | scalar value greater than 0

    Font size, specified as a scalar value greater than 0 in point units. One point equals 1/72 inch. To change the font units, use the FontUnits property.

    If you add a title or subtitle to an axes object, then the font size property for the axes also affects the font size for the title and subtitle. The title and subtitle font sizes are the axes font size multiplied by a scale factor. The FontSize property of the axes contains the axes font size. The TitleFontSizeMultiplier property of the axes contains the scale factor. By default, the axes font size is 10 points and the scale factor is 1.1, so the title and subtitle each have a font size of 11 points.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    FontWeightThickness of text characters
    'normal' (default) | 'bold'

    Thickness of the text characters, specified as one of these values:

    • 'normal' — Normal weight as defined by the particular font

    • 'bold' — Thicker characters outlines than normal

    MATLAB® uses the FontWeight property to select a font from those available on your system. Not all fonts have a bold font weight. Therefore, specifying a bold font weight could still result in the normal font weight.

    The SubtitleFontWeight property for the associated axes affects the FontWeight value for the subtitle.

    Tips

    • By default, the Interactions property contains editInteraction so the text can be edited by clicking on the text. To disable this interaction, set the Interactions property of the text object to [].

    Version History

    Introduced in R2020b

    See Also

    Functions

    • title

    Properties

    • Text Properties

    MATLAB Command

    You clicked a link that corresponds to this MATLAB command:

     

    Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

    Add subtitle to plot - MATLAB subtitle (14)

    Select a Web Site

    Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

    You can also select a web site from the following list:

    Americas

    • América Latina (Español)
    • Canada (English)
    • United States (English)

    Europe

    • Belgium (English)
    • Denmark (English)
    • Deutschland (Deutsch)
    • España (Español)
    • Finland (English)
    • France (Français)
    • Ireland (English)
    • Italia (Italiano)
    • Luxembourg (English)
    • Netherlands (English)
    • Norway (English)
    • Österreich (Deutsch)
    • Portugal (English)
    • Sweden (English)
    • Switzerland
      • Deutsch
      • English
      • Français
    • United Kingdom (English)

    Asia Pacific

    • Australia (English)
    • India (English)
    • New Zealand (English)
    • 中国
    • 日本 (日本語)
    • 한국 (한국어)

    Contact your local office

    Add subtitle to plot - MATLAB subtitle (2024)

    References

    Top Articles
    NH Law About ...: Legal Links: For New Hampshire Law ...
    Mezeh Nutrition Calculator
    Gasbuddy Joliet
    Msc Open House Fall 2023
    Coverwood Terriers For Sale
    7076605599
    Redbox Locations Walmart
    Hailie Deegan News, Rumors, & NASCAR Updates
    Relic Gate Nms
    888-490-1703
    Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
    Sam's Club Key Event Dates 2023 Q1
    Martimelons
    Inside the Rise and Fall of Toys ‘R’ Us | HISTORY
    Walking through the Fire: Why nothing stops Jesus’ love for you - Ann Voskamp
    Craigslist Manhattan Ks Personals
    Kroger Liquor Hours
    Fandango Movies And Shows
    New from Simply So Good - Cherry Apricot Slab Pie
    Lucio Surf Code
    Rockcastle County Schools Calendar
    Open jazz : podcast et émission en replay | France Musique
    Craiglist Rhode Island
    Chi Trib Weather
    No Prob-Llama Plotting Points
    Axolotls for Sale - 10 Online Stores You Can Buy an Axolotl - Axolotl Nerd
    Movierulz.com Kannada 2024 Download: Your Ultimate Guide
    Retire Early Wsbtv.com Free Book
    Haktuts.in Coin Master 50 Spin Link
    Panic! At The Disco - Spotify Top Songs
    How 'Tuesday' Brings Death to Life With Heart, Humor, and a Giant Bird
    When Is Meg Macnamara Due
    Uhauldealer.com Login Page
    Mike Temara
    South Carolina Title Transfer Does Sc Require Notary Seal For Auto Title Transfer
    Oklahoma Scratch Off Remaining Prizes
    Journal articles: 'New York (State). First Congregational Church' – Grafiati
    Snowy Hydro Truck Jobs in All Sydney NSW - Sep 2024 | SEEK
    Brian Lizer Life Below Zero Next Generation
    Stark Cjis Court Docket
    Lagniappemobile
    How to Survive (and Succeed!) in a Fast-Paced Environment | Exec Learn
    Fandafia
    Rockin That Orange Jumpsuit Columbia County
    Sam's Club Hiring Near Me
    El Pulpo Auto Parts Houston
    The Swarthmorean, 1932-05 | TriCollege Libraries Digital Collections
    Fintechzoommortgagecalculator.live Hours
    Guy Ritchie's The Covenant Showtimes Near Century 16 Eastport Plaza
    How Long Ago Was February 28 2023
    Cb2 South Coast Plaza
    Latest Posts
    Article information

    Author: Rev. Porsche Oberbrunner

    Last Updated:

    Views: 5611

    Rating: 4.2 / 5 (73 voted)

    Reviews: 80% of readers found this page helpful

    Author information

    Name: Rev. Porsche Oberbrunner

    Birthday: 1994-06-25

    Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

    Phone: +128413562823324

    Job: IT Strategist

    Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

    Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.