- 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 display only a left and bottom box border in Matplotlib?
To display or hide box border in matplotlib, we can use spines (value could be right, left, top or bottom) and set_visible() method to set the visibility to True or False.
Steps
Create x and y data points using numpy.
Create a figure and add a set of subplots using subplots() method.
Plot x and y data points using plot() method, where linewidth=7 and color=red.
Set visibility as True for left and bottom, and False for top and right.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 10) y = np.sin(x) fg, ax = plt.subplots() ax.plot(x, y, lw=7, c='red') ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) ax.spines['left'].set_visible(True) ax.spines['bottom'].set_visible(True) plt.show()
Output
- Related Articles
- CSS border-bottom-left-radius property
- Set bottom-left corner border with CSS
- Drawing a rectangle with only border in Matplotlib
- How to create a Box to display components from left to right in Java
- How to display the JList items from top to bottom and left to right in Java?
- Perform Animation on CSS border-bottom-left-radius property
- How to show (0,0) on matplotlib graph at the bottom left corner?
- Turn off the left/bottom axis tick marks in Matplotlib
- How to add a border to the top and bottom of an iOS View?
- How to add a border to the top and bottom of an Android View?
- How to put xtick labels in a box matplotlib?
- MySQL query to display only 15 words from the left?
- How to display only hour and minutes in MySQL?
- Animate CSS border-bottom property
- CSS border-box Value

Advertisements