×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Logit Scale in Plotting

In this article, we are going to learn how to change y-axis scale from linear to logit in Python plot using matplotlib?
Submitted by Anuj Singh, on August 20, 2020

When we need to plot data in logit form, then we can use an inbuilt defined function matplotlib.pyplot.yscale('logit').

We have illustrated the usage using the below example and also compared it with the linear scale in the subplot.

Illustrations:

Python | Logit Scale in Plotting (1)

Python | Logit Scale in Plotting (2)

Python code for logit scale in plotting

import matplotlib.pyplot as plt
import numpy as np

y = np.random.normal(loc=0.5, scale=0.4, size=1000)
y = y[(y > 0) & (y < 1)]
y.sort()
x = np.arange(len(y))

plt.figure()
plt.plot(x, y)
plt.title('linear scale')
plt.grid(True)
plt.show()

plt.figure()
plt.plot(x, y)
plt.yscale('logit')
plt.title('logit scale')
plt.grid(True)
plt.show()

Output:

Output is as Figure
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.