Python | Symmetric Log Scale Example in Matplotlib

In this article, we are going to set both the axes with symmetric log scale mathematical data visualization.
Submitted by Anuj Singh, on August 14, 2020

Illustration:

Symmetric Log Scale Example (1)

Symmetric Log Scale Example (2)

Symmetric Log Scale Example (3)

Python code for symmetric log scale example in matplotlib

import matplotlib.pyplot as plt
import numpy as np

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

plt.figure(figsize=(7,12))
plt.subplot(311)
plt.plot(x, np.sin(x / 7.0), 'r-', linewidth=0.5)
plt.xscale('symlog')
plt.yscale('symlog', linthresh=0.015)
plt.grid(True)
plt.ylabel('symlog both')
plt.grid()
plt.tight_layout()


plt.subplot(312)
plt.plot(y, x, 'o', color='yellow')
plt.yscale('symlog')
plt.ylabel('symlogy')
plt.grid()

plt.subplot(313)

plt.plot(x, y, linewidth=2.0)
plt.xscale('symlog')
plt.ylabel('symlogx')
plt.grid(True)
plt.show()

Output:

Output is as Figure


Comments and Discussions!

Load comments ↻





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