Make a Log Histogram in Python



To make a log histogram, we can use log=True in the argument of the hist() method.

Steps

  • Make a list of numbers.

  • Plot a histogram with density=True.

  • 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
k = np.array([5, 5, 5, 5])
x, bins, p = plt.hist(np.log(k), density=True, log=True)
plt.show()

Output

Updated on: 2021-05-07T07:44:51+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements