How to Create an Empty Figure with Matplotlib in Python? Last Updated : 11 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Creating a figure explicitly is an object-oriented style of interfacing with matplotlib. The figure is a basic building block of creating a plot as Matplotlib graphs our data on figures. This figure keeps track of all other components such as child axes, legends, title, axis, etc. Steps to create an empty figure : First, we import the matplotlib library specifically the pyplot module of matplotlib.Then we create a figure object using plt.figure() and keep a reference to that by setting it equal to the 'fig' variable. This figure object is empty as we have not added any figure components such as axis, legend, axis, etc.We are using jupyter notebook, and we have to change out backend to ipympl(interactive backend) as with the default backend it was showing a Non-Gui backend error. For installing the ipympl run this command into your terminal: For conda environment. conda install ipympl -c conda-forge For normal python terminal: pip install ipympl Below is the implementation: Example1 : Python3 # importing the library import matplotlib # Enabling interactive backend ipympl in # jupyter notebook or you can use # any other backend %matplotlib ipympl import matplotlib.pyplot as plt # an empty figure with no axes fig = plt.figure() Output: Example 2 : You can also use another interactive backend to display your figure like TkAgg( requires TkInter installed). Python3 # using different backend import matplotlib %matplotlib tk import matplotlib.pyplot as plt #creating a figure fig = plt.figure() Output : Figure2_gfg Note: Displaying the figure in a different editor or python shell will need you to play with backends. show() method also displays an empty figure but you have to save that figure before using show() command. Example : In the following example, I have used figsize attribute to change the size of the figure. Python3 import matplotlib # changing backend %matplotlib tk import matplotlib.pyplot as plt # saving the figure plt.savefig('testfigure.png', dpi = 100) # displaying the figure plt.show() Output : figure3_gfg Comment More infoAdvertise with us Next Article How to Create Matplotlib Plots Without a GUI T tejalkadam18m Follow Improve Article Tags : Python Python-matplotlib Practice Tags : python Similar Reads How to Add Axes to a Figure in Matplotlib with Python? Matplotlib is a library in Python used to create figures and provide tools for customizing it. It allows plotting different types of data, geometrical figures. In this article, we will see how to add axes to a figure in matplotlib. We can add axes to a figure in matplotlib by passing a list argument 2 min read How to create an empty matrix with NumPy in Python? In Python, an empty matrix is a matrix that has no rows and no columns. NumPy, a powerful library for numerical computing, provides various methods to create matrices with specific properties, such as uninitialized values, zeros, NaNs, or ones. Below are different ways to create an empty or predefin 3 min read How to Create Subplots in Matplotlib with Python? Matplotlib is a widely used data visualization library in Python that provides powerful tools for creating a variety of plots. One of the most useful features of Matplotlib is its ability to create multiple subplots within a single figure using the plt.subplots() method. This allows users to display 6 min read How to Create Matplotlib Plots Without a GUI To create and save plots using Matplotlib without opening a GUI window, you need to configure Matplotlib to use a non-interactive backend. This can be achieved by setting the backend to 'Agg', which is suitable for generating plots without displaying them. Let's see how to set the backend to Agg: Me 2 min read How to Add Multiple Axes to a Figure in Python In this article, we are going to discuss how to add multiple axes to a figure using matplotlib in Python. We will use the add_axes() method of matplotlib module to add multiple axes to a figure. Step-by-step Approach: Import required modulesAfter importing matplotlib, create a variable fig and equal 3 min read How to add a grid on a figure in Matplotlib ? Matplotlib library is widely used for plotting graphs. In many graphs, we require to have a grid to improve readability. Grids are created by using grid() function in the Pyplot sublibrary. In this article, we will see how to add grid in Matplotlb. Add a Grid on a Figure in MatplotlibBelow are the w 3 min read Like