

- 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
Logarithmic Y-axis bins in Python
To plot logarithmic Y-axis bins in Python, we can take the following steps −
Create x and y points using numpy.
Set the Y-axis scale using the yscale() method.
Plot the x and y points, using the plot() method with linestyle="dashdot" and label="y=log(x)".
To activate the label of the line, use the legend() method.
To display the figure, use the 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 x = np.linspace(1, 100, 1000) y = np.log(x) plt.yscale('log') plt.plot(x, y, c="red", lw=3, linestyle="dashdot", label="y=log(x)") plt.legend() plt.show()
Output
- Related Questions & Answers
- How to have logarithmic bins in a Python histogram?
- How to specify values on Y-axis in Python Matplotlib?
- Y-axis 3D transform with CSS3
- Setting Y-axis in Matplotlib using Pandas
- How to set the Y-axis in radians in a Python plot?
- Overlapping Y-axis tick label and X-axis tick label in Matplotlib
- Transform the element by using x-axis, y-axis, and z-axis with CSS3
- How to remove Y-axis labels in R?
- Transform the element along with x-axis and y-axis with CSS
- Plot two horizontal bar charts sharing the same Y-axis in Python Matplotlib
- Show the origin axis (x,y) in Matplotlib plot
- Transform the element using y-axis with CSS3
- Rotate div with skew y-axis using CSS
- How to change the range of the X-axis and Y-axis in Matplotlib?
- Create ggplot2 graph with reversed Y-axis and X-axis on top in R.
Advertisements