
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
Found 1034 Articles for Matplotlib

5K+ Views
To embed a matplotlib animation into a tkinter frame, we can take the following stepsStepsSet the figure size and adjust the padding between and around the subplots.Create a Toplevel widget of Tk which represents mostly the main window of an applicationSet the title of this widget.Add an axes to the current figure and make it the current axes.Create a new figure or activate an existing figure.Add an 'ax' to the figure as part of a subplot arrangement.Make a dummy line plot with linewidth=2.Create the canvas the figure renders into.Create the figure canvas on which to operate.Create a keypress event to ... Read More

5K+ Views
To save multiple figures in one PDF file at once, we can take follwong stepsStepsSet the figure size and adjust the padding between and around the subplots.Create a new figure (fig1) or activate and existing figure using figure() method.Plot the first line using plot() method.Create another figure (fig2) or activate and existing figure using figure() method.Plot the second line using plot() method.Initialize a variable, filename, to make a pdf file.Create a user-defined function save_multi_image() to save multiple images in a PDF file.Call the save_multi_image() function with filename.Create a new PdfPages object.Get the number of open figures.Iterate the opened figures and ... Read More

2K+ Views
The Python Matplotlib library allows us to create visual plots from given data. To make the data easier to read and relate to the chart, we can display it in the form of a table and position it directly below the corresponding bar chart. Since the x-axis runs horizontally, we arrange the table in the same direction so that each value aligns correctly under its corresponding bar. Based on this concept, we demonstrate the diagram as follows: Steps to Align a Table to the X-axis Using Matplotlib Following are the steps to create a table and store data ... Read More

4K+ Views
To plot int to datetime on X-axis using Seaborn in matplotlib, we can take the following stepsStepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data, with three columns.Create a countplot with int, i.e., dob on the X-axis.Set int to datetime label on the X-axis.To display the figure, use Show() method.Exampleimport seaborn as sns from matplotlib import pyplot as plt import pandas as pd import numpy as np # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Data frame with 3 ... Read More

5K+ Views
To show a 2D array as a grayscale image in Jupyter Notebook, we can take the following stepsStepsSet the figure size and adjust the padding between and around the subplots.Create a random data using numpy.Display the data as an image, i.e., on a 2D regular raster, with gray colormap.To display the figure, use Show() method.Examplefrom matplotlib import pyplot as plt import numpy as np # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Random data points data = np.random.rand(5, 5) # Plot the data using imshow with gray colormap plt.imshow(data, cmap='gray') # ... Read More

2K+ Views
To fill the region between a curve and X-axis in Python using Matplotlib, we can take the following stepsStepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot the x and y data points using plot() method.Fill the area between the curve and the X-axis using fill_between() method.To display the figure, use Show() method.Exampleimport matplotlib.pyplot as plt import numpy as np # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create x and y data points x = np.linspace(-5, 5, 100) y = np.sin(x) ... Read More

783 Views
To use colorbar with hist2d in matplotlib.pyplot, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Initialize a variable "N" for the number of sample data.Createx and y data points using numpy.Create a figure and a set of subplots using subplots() method.Make a 2D histogram plot using hist2D().Create a colorbar for the hist2d scalar mappable instance.To display the figure, use Show() method.Examplefrom matplotlib.colors import LogNorm import matplotlib.pyplot as plt import numpy as np # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Number of sample data ... Read More

2K+ Views
To use unicode symbols in matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Add text to figure, using text() method with unicode symbols. Here we have used the Unicode chararacter (Δ) which has the character code (0394).To display the figure, use Show() method.Exampleimport matplotlib.pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Unicode symbol plt.text(0.5, 0.5, s=u"\u0394", fontsize=50) # Display the plot plt.show() OutputIt will produce the following output −Now, let's use another Unicode character (\u2734).It will produce the following ... Read More

190 Views
To build colorbars without attached plot in matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Adjust the subplot layout parameters.Normalize the quaternion in place. Return the norm of the quaternion.Get the colorbar instance (cb) with base colorbar and horizontal orientation.To display the figure, use Show() method.Exampleimport matplotlib.pyplot as plt import matplotlib as mpl # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create a figure and a set of subplots fig, ax = plt.subplots() # Adjust ... Read More

2K+ Views
Tp append a single labeled tick to X-axis using matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y data points using plot() method.Set xticks at a single point.Set the tick label for single tick point.To display the figure, use Show() method.Exampleimport numpy as np import matplotlib.pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create x and y data points x = np.linspace(-5, 5, 50) y = np.sin(x) # Plot ... Read More