EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab Figure
 

Matlab Figure

Priya Pedamkar
Article byPriya Pedamkar

Updated February 28, 2023

Matlab Figure

 

 

Introduction to Matlab Figure

MATLAB provides us with plenty of functionalities, useful in various computational problems. In addition to its computational capabilities, MATLAB is also a great tool for visualization. It provides us with the ability to plot a wide variety of charts. Apart from showing graphical output in the console, MATLAB can also have our graphical output displayed in a separate window. For achieving this, we need to create a ‘figure object’ in MATLAB using figure function, which we will learn in this article.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Figure function, MATLAB

For creating the figure object, MATLAB creates a separate window. The characteristics of this new window can be controlled using figure properties specified as arguments (Please refer to the end of the article for the custom properties).

Table for Custom Properties

here is the table for custom property:

Property

Description

Value/s

Color To set the background color Pre-defined color code
Default: As per the color scheme
MenuBar To toggle the menu bar on/off none, figure
Default: figure
Name To set the title string
Default: ” (empty string)
number title To display the figure number on, off
Default: on
Resize For resizing the figure window using the mouse on, off
Default: on
SelectionHighlight To highlight the figure on, off
Default: on
Visible Makes figure visible/invisible on, off
Default: on
WindowStyle Normal/modal window normal, modal

Default: normal

Syntax

figure (Name, Value)

We will first understand figure function in its simplest form where we will create a figure & specify the property “Name”.For this example, we will pass “Name” property as ‘Learning figure function’

Examples to Implement Matlab Figure

Here are some examples mentioned:

Example #1

This is how our input and output will look like in MATLAB console:

Code:

figure ('Name', 'Learning figure function')

Output:

Matlab Figure1

Explanation: As we can observe in the output obtained, we have obtained a new window as a figure object and our figure’s name is as passed by us “Learning figure function”. Also, notice ‘Figure 1’ before the name of the figure, this is done by MATLAB as a default property. However, we can get rid of this.

Example #2

Let us learn how to get the name without the figure number. To achieve this, we need to keep the ‘Numbertitle’ property of figure function as ‘off’. This is how our input and output will look like in MATLAB console:

Code:

figure('Name', 'Learning figure function','NumberTitle','off');

Output:

Matlab Figure2

Note: In the output that we have obtained a new window without the figure number.

Example #3

Next we will learn how we can get our graph in the figure object.  To get the graph in a new window, we first create the figure object as above and then write the syntax to create the desired plot. MATLAB by default assigns the plot to the latest figure object created.

In our example, we will create a bar plot in the figure object.

X = [12, 20, 13, 40, 40, 23, 54, 65, 11, 40, 70, 45, 60, 33][Input array to create bar plot]

This is how our input and output will look like in MATLAB console:

Code:

X = [12, 20, 13, 40, 40, 23, 54, 65, 11, 40, 70, 45, 60, 33] figure ('Name', 'Learning figure function','NumberTitle','off')
bar (X)

Output:

Matlab Figure3

Example #4

As we can see, our output bar chart is in a new window and with the name as passed by us. We can also change the background of the new window using the ‘Color’ property of figure function. Let us learn how to do that.

For our example, we will set the ‘Color’ property to ‘c’ which is pre-defined color code for the color cyan.

Note: In the above line of code that we have set the ‘Color’ property as ‘c’ to get Cyan color

This is how our input and output will look like in MATLAB console:

Code:

X = [12, 20, 13, 40, 40, 23, 54, 65, 11, 40, 70, 45, 60, 33] figure ('Name', 'Learning figure function','NumberTitle','off', 'Color', 'c')
bar (X)

Output:

background Color

Explanation: So, we have our output window in CYAN color now.

Example #5

Let us take another example where we will create a scatter plot in a new window using figure function. For this example, we will get our background in Red color.

scatter((1:40),and(1,40)); [Creating scatter plot using random values]

As explained earlier, MATLAB will by default plot the graph in the figure object created. This is how our input and output will look like in MATLAB console:

Code:

figure ('Name', 'Learning figure function', 'NumberTitle', 'off', 'Color','r')
scatter((1:40),rand(1,40));

Output:

scatter plot

Explanation: As we can see in our output, we have our scatter plot created in a new window, with red color.

Conclusion

figure function in MATLAB is used if we want our plot to be created in a separate window. We can control the look and feel of the new window using the properties of the figure function.

Recommended Articles

This is a guide to Matlab Figure. Here we discuss an introduction to Matlab Figure, Table for custom properties, syntax, examples with code and output. You can also go through our other related articles to learn more –

  1. Matlab Plot Circle
  2. Nested Loop in Matlab
  3. Colormap in Matlab
  4. Colors in Matlab

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Limited Time Offer! - ENROLL NOW