Python | Antialiasing in Plotting

Python | Antialiasing in Plotting: In this article, we are going to learn about the antialiasing in plotting and its Python implementation.
Submitted by Anuj Singh, on July 11, 2020

Antialiasing is another important feature of Matplotlib and in this article, we will review how to use this functionality. pyplot.antialiased() is an inbuilt function in matplotlib.pyplot which performs our required operation.

Syntax:

line, = plt.plot(x, y, '-')
line.set_antialiased(False) # turn off antialiasing
Python | Antialiasing in Plotting (1)

Python | Antialiasing in Plotting (2)

Python code for antialiasing in plotting

# Data Visualization using Python
# Antialiasing

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(50)
y = 60 + np.random.randint(50,70,50)

plt.figure()
plt.title('Antialiased OFF')
line, = plt.plot(x, y)
# turn off antialiasing
line.set_antialiased(False) 

plt.figure()
plt.title('Antialiased ON')
line, = plt.plot(x, y)
# turn on antialiasing
line.set_antialiased(True) 

Output:

Output is as figure





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.