- 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
How to plot y=1/x as a single graph in Python?
To plot y=1/x as a single graph in Python, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create data points using numpy.
- Plot x and 1/x data points using plot() method.
- Place a legend on the figure.
- To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 101) plt.plot(x, 1/x, label='$f(x)=\frac{1}{x}$') plt.legend(loc='upper left') plt.show()
Output
- Related Articles
- How to plot a graph in Python?
- How can matplotlib be used to plot 3 different datasets on a single graph in Python?
- Draw the graph of $y=x+1$.
- Python - How to plot a Pandas DataFrame in a Bar Graph
- How to plot values with log scales on x and y axis or on a single axis in R?
- How to Add Markers to a Graph Plot in Matplotlib with Python?
- How to plot a smooth 2D color plot for z = f(x, y) in Matplotlib?
- 1. Factorize the expression \( 3 x y - 2 + 3 y - 2 x \)A) \( (x+1),(3 y-2) \)B) \( (x+1),(3 y+2) \)C) \( (x-1),(3 y-2) \)D) \( (x-1),(3 y+2) \)2. Factorize the expression \( \mathrm{xy}-\mathrm{x}-\mathrm{y}+1 \)A) \( (x-1),(y+1) \)B) \( (x+1),(y-1) \)C) \( (x-1),(y-1) \)D) \( (x+1),(y+1) \)
- How can I plot a single point in Matplotlib Python?
- How to plot single data with two Y-axes (two units) in Matplotlib?
- How to set the Y-axis in radians in a Python plot?
- Python - Plot a Pandas DataFrame in a Line Graph
- Plot a 3D surface from {x,y,z}-scatter data in Python Matplotlib
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- How to plot a high resolution graph in Matplotlib?

Advertisements