×

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 | Symmetric Log Scale for Y axis in Matplotlib

In this article, we are going to set y axis scale as symlog for mathematical data visualization.
Submitted by Anuj Singh, on August 14, 2020

When we need to plot data in symmetric logarithmic form, then we can use an inbuilt defined function matplotlib.pyplot.yscale('symlog'). We have illustrated the usage using the below example and also compared it with the linear scale in the subplot.

Illustration:

Symmetric Log Scale for Y axis (1)

Symmetric Log Scale for Y axis (2)

Python code for symmetric log scale for y axis in matplotlib

import numpy as np
import matplotlib.pyplot as plt

dt = 1 
x = np.arange(-50.0, 50.0, dt)
y = np.arange(0, 100.0, dt)

plt.figure()
plt.plot(x, y, '.', color='purple')
plt.title('Y Scale : Symlog')
plt.yscale('symlog')
plt.show()

y = np.exp(-x)
plt.figure()
plt.plot(x, y, '.', color='purple')
plt.title('YScale : Symlog')
plt.yscale('symlog')
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.