
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
Change Figsize for Matshow in Jupyter Notebook using Matplotlib
To change the figsize for mathshow, we can use figsize in figure method argument and use fignum in matshow() method.
Steps
- Create a new figure or activate an existing figure using figure() method.
- Create a dataframe using Pandas.
- Use matshow() method to display an array as a matrix in a new figure window.
- The argument fignum can take the values None, int, or False
- If *None*, create a new figure window with automatic numbering.
- If a nonzero integer, draw into the figure with the given number. Create one, if it does not exist.
- If 0, use the current axes (or create one if it does not exist).
- To display the figure, use show() method.
Example
import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True plt.figure() df = pd.DataFrame({"col1": [1, 3, 5, 7, 1], "col2": [1, 5, 7, 9, 1]}) plt.matshow(df.corr(), fignum=1) plt.show()
Output
Advertisements