Matplotlib.axes.Axes.fill() in Python (original) (raw)
Last Updated : 13 Apr, 2020
Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
matplotlib.axes.Axes.fill() Function
The Axes.fill() function in axes module of matplotlib library is used to plot filled polygons.
Syntax:
Axes.fill(self, *args, data=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
- *args: These parameter are the lists of x and y positions of its nodes, optionally followed by a color specifier.
- data: This parameter is an optional parameter and it is an object with labelled data. Returns: This returns the list of Polygon.
Below examples illustrate the matplotlib.axes.Axes.fill() function in matplotlib.axes:Example-1:
Python3 `
Implementation of matplotlib function
import numpy as np from matplotlib import patches import matplotlib.pyplot as plt
x = np.array([1, 4, 1, 4]) y = np.array([1, 1, 4, 4])
fig, ax1 = plt.subplots() ax1.fill(x, y, facecolor ='green') ax1.set_title('matplotlib.axes.Axes.fill Example 1') plt.show()
`
Output: Example-2:
Python3 `
Implementation of matplotlib function
import numpy as np from matplotlib import patches import matplotlib.pyplot as plt
theta = np.deg2rad(np.arange(0.0, 360.0, 1.0)) x = 0.5 * np.cos(theta) y = 0.5 * np.sin(theta)
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize =(9, 3), subplot_kw ={'aspect': 'equal'}, sharey = True) ax1.fill(x, y, facecolor ='green') ax1.set_title('Fig 1')
ax2.fill(x, y, facecolor ='green', edgecolor ='black', linewidth = 4)
ax2.set_title('Fig 2')
ax3.fill(x, y, facecolor ='none', edgecolor ='green', linewidth = 4) ax3.set_title('Fig 3')
plt.show()
`
Output:
Similar Reads
- Python Tutorial | Learn Python Programming Language Python Tutorial – Python is one of the most popular programming languages. It’s simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly.Python is:A high-level language, used in web development, data science, automatio 10 min read
- Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth 15+ min read
- Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p 11 min read
- Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether you’re a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Here’s a list 10 min read
- Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test 9 min read
- Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co 11 min read
- Python Data Types Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of thes 9 min read
- Enumerate() in Python enumerate() function adds a counter to each item in a list or other iterable. It turns the iterable into something we can loop through, where each item comes with its number (starting from 0 by default). We can also turn it into a list of (number, item) pairs using list().Let's look at a simple exam 3 min read
- Python Lists In Python, a list is a built-in dynamic sized array (automatically grows and shrinks). We can store all types of items (including another list) in a list. A list may contain mixed type of items, this is possible because a list mainly stores references at contiguous locations and actual items maybe s 6 min read
- Python Introduction Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.Key Features of PythonPython’s simple and readable syntax makes it beginner-frien 3 min read