- Trending Categories
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
Setting Y-axis in Matplotlib using Pandas
To set Y-Axis in matplotlib using Pandas, we can take the following steps −
Create a dictionary with the keys, x and y.
Create a data frame using Pandas.
Plot data points using Pandas plot, with ylim(0, 25) and xlim(0, 15).
To display the figure, use show() method.
Example
import numpy as np import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True d = dict( x=np.linspace(0, 10, 10), y=np.linspace(0, 10, 10)*2 ) df = pd.DataFrame(d) df.plot(kind="bar", ylim=(0, 25), xlim=(0, 15)) plt.show()
Output
- Related Articles
- Automatically setting Y-axis limits for a bar graph using Matplotlib
- Preserve padding while setting an axis limit in matplotlib
- Setting the same axis limits for all subplots in Matplotlib
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- Setting active subplot using axes object in Matplotlib
- Overlapping Y-axis tick label and X-axis tick label in Matplotlib
- Show the origin axis (x,y) in Matplotlib plot
- Pandas timeseries plot setting X-axis major and minor ticks and labels
- Plot a histogram with Y-axis as percentage in Matplotlib
- How to share secondary Y-axis between subplots in Matplotlib?
- How to specify values on Y-axis in Python Matplotlib?
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?
- How to exponentially scale the Y axis with matplotlib?
- How to display Matplotlib Y-axis range using absolute values rather than offset values?

Advertisements