
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Difference Between Log and Symlog in Matplotlib
Log helps to make a plot with log scaling on both the X and Y axis, whereas symlog (symmetric log) is used for axis scaling.
Steps
First, we can adjust the subplot layout parameters.
Return an evenly spaced value (t) within a given interval, using the numpy.arrange() method.
Add a subplot to the current figure, with nrows = 1, ncols = 2 and current index is 1.
Make a plot with log scaling on the Y axis, using the semilogy() method.
Set the title for the axes, using the plt.title() method.
Configure the grid lines, using the grid(True) method.
Create two evenly spaced values within a given interval using the numpy.arrange() method.
Add a subplot to the current figure with nrows = 1, ncols = 2 and current index is 2.
Plot using the plt.plot() method with two lists that have been created in step 7.
Set the X-axis scale, using xscale.
Set the title for the axes, using the plt.title() method.
Configure the grid lines, using the grid(True) method.
To show the figure, use the plt.show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.subplots_adjust(hspace=0.4) t = np.arange(0.01, 20.0, 0.01) # log y axis plt.subplot(121) plt.semilogy(t, np.exp(-t/5.0)) plt.title('Log') plt.grid(True) x = np.arange(-50.0, 50.0, 0.01) y = np.arange(0, 100.0, 0.01) plt.subplot(122) plt.plot(x, y) plt.xscale('symlog') plt.title('Symmetry Log') plt.grid(True) plt.show()