- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 do you draw R-style axis ticks that point outward from the axes in Matplotlib?
To draw R-style (default is regular style) axis ticks that point outward from the axes in matplotlib, we can use rcParams["xticks.direction"]="out" for X-axis.
Steps
Set the figure size and adjust the padding between and around the subplots.
Set outwaord tick points using plt.rcParams.
Initialize a variable for the number of data points.
Create x and y data points using numpy.
Plot x and y data points using plot() method.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.rcParams['ytick.direction'] = 'out' # in plt.rcParams['xtick.direction'] = 'out' # in n = 10 x = np.linspace(-2, 2, n) y = np.exp(x) plt.plot(x, y) plt.show()
Output
Advertisements