
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to remove a frame without removing the axes tick labels from a Matplotlib figure in Python?
To remove a frame without removing the axes tick labels from a Matplotlib figure, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create a list of y data points.
- Plot the y data points using plot() method
- To remove the left-right-top and bottom spines, we can use set_visible() method.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True y = [0, 2, 1, 5, 1, 2, 0] plt.plot(y, color='red', lw=7) for pos in ['right', 'top', 'bottom', 'left']: plt.gca().spines[pos].set_visible(False) plt.show()
Output
- Related Articles
- How to rotate tick labels in a subplot in Matplotlib?
- Hiding major tick labels while showing minor tick labels in Matplotlib
- How to change the separation between tick labels and axis labels in Matplotlib?
- How to remove the tick labels in JavaFX XY charts?
- How to show tick labels on top of a matplotlib plot?
- Create a graph using ggplot2 without axes ticks and axes labels.
- Centering x-tick labels between tick marks in Matplotlib
- Create a ggplot2 graph without axes labels, axes titles and ticks in R.
- How to create boxplot in base R without axes labels?
- How to show minor tick labels on a log-scale with Matplotlib?
- How can I move a tick label without moving corresponding tick in Matplotlib?
- How to decrease the density of tick labels in subplots in Matplotlib?
- Getting empty tick labels before showing a plot in Matplotlib
- How to better rasterize a plot without blurring the labels in matplotlib?
- How to remove or hide X-axis labels from a Seaborn / Matplotlib plot?

Advertisements