- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot a half-black and half-white circle using Matplotlib?
To plot a half-black and half-white circle using Matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create a figure and a set of subplots.
- Initialize theta1 and theta2 to draw edges from theta1 to theta2 and vice-versa.
- Add the wedge instance on the current axes.
- Set equal scaling by changing axis limits.
- Set x and y scale.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt from matplotlib.patches import Wedge plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() theta1, theta2 = 0, 0 + 180 radius = 2 center = (0, 0) w1 = Wedge(center, radius, theta1, theta2, fc='black', edgecolor='black') w2 = Wedge(center, radius, theta2, theta1, fc='white', edgecolor='black') for wedge in [w1, w2]: ax.add_artist(wedge) ax.axis('equal') ax.set_xlim(-5, 5) ax.set_ylim(-5, 5) plt.show()
Output
- Related Articles
- Plot a black-and-white binary map in Matplotlib
- How to plot half or quarter polar plots in Matplotlib?
- How to plot a circle in Matplotlib?
- How to Create a Black and White Image Using CSS
- How to create a black image and a white image using OpenCV Python?
- How to plot a rectangle inside a circle in Matplotlib?
- What is Half Duplex mode? Differentiate between half duplex and full duplex?
- How to create a "black and white" image with CSS?
- What is the concept of half human and half beast in Hindu mythology?
- Plot a circle with an edgecolor and hatch in Matplotlib
- Plot a circle inside a rectangle in Matplotlib
- How to create a black and white word cloud in R?
- How to change the plot line color from blue to black in Matplotlib?
- Half Wave Rectifier
- How to plot a wav file using Matplotlib?

Advertisements