

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 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 Questions & Answers
- How to rotate tick labels in a subplot in Matplotlib?
- Hiding major tick labels while showing minor tick labels in Matplotlib
- Create a graph using ggplot2 without axes ticks and axes labels.
- How to remove the tick labels in JavaFX XY charts?
- How to change the separation between tick labels and axis labels in Matplotlib?
- How to show tick labels on top of a matplotlib plot?
- Centering x-tick labels between tick marks in Matplotlib
- Create a ggplot2 graph without axes labels, axes titles and ticks in R.
- How can I move a tick label without moving corresponding tick in Matplotlib?
- Getting empty tick labels before showing a plot in Matplotlib
- How to show minor tick labels on a log-scale with Matplotlib?
- How to create boxplot in base R without axes labels?
- How to better rasterize a plot without blurring the labels in matplotlib?
- How to decrease the density of tick labels in subplots in Matplotlib?
- How to combine several matplotlib axes subplots into one figure?
Advertisements