Matplotlib Articles

Page 27 of 91

How to plot MFCC in Python using Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 1K+ Views

MFCC (Mel-Frequency Cepstral Coefficients) are widely used features in audio processing and speech recognition. Python's python_speech_features library combined with Matplotlib allows us to extract and visualize these features effectively. What are MFCCs? MFCCs represent the shape of the spectral envelope of audio signals. They capture the most important characteristics of audio for speech recognition and audio analysis tasks. Installing Required Libraries First, install the necessary packages ? pip install python_speech_features matplotlib scipy numpy Step-by-Step Implementation Here's how to extract and plot MFCC features from an audio file ? from ...

Read More

How can I convert from scatter size to data coordinates in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 382 Views

Converting scatter plot marker sizes to data coordinates in Matplotlib helps you understand the actual data scale represented by marker sizes. This is useful for creating size legends or performing calculations based on visual marker dimensions. Basic Scatter Plot with Size Array First, let's create a scatter plot with different marker sizes ? import numpy as np import matplotlib.pyplot as plt # Set figure parameters plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create data points X = np.array([[1, 1], [2, 1], [2.5, 1]]) s = np.array([20, 10000, 10000]) # Create scatter plot ...

Read More

How to load a .ttf file in Matplotlib using mpl.rcParams?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 547 Views

To load a custom .ttf file in Matplotlib using mpl.rcParams, you need to register the font with the font manager and set it as the default font family. This allows you to use custom fonts that aren't installed system-wide. Basic Font Loading Process The process involves these key steps − Import the required modules: pyplot and font_manager Create a FontProperties object from the .ttf file path Extract the font name using get_name() Set the font family in rcParams Apply the font to your plots Example Here's how to load and use a custom ...

Read More

Scroll backwards and forwards through Matplotlib plots

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 2K+ Views

To scroll backward and forwards through Matplotlib plots using left and right arrow keys, we can bind a key press event to dynamically update the plot data. This technique is useful for creating interactive visualizations where users can navigate through different views of data. Steps to Create Scrollable Plots Set up the figure size and padding configuration Create initial data points using NumPy Define a key event handler function to respond to arrow keys Bind the key press event to the figure Add a subplot and plot the initial data Use show() to display the interactive plot ...

Read More

How to increase the thickness of error line in a Matplotlib bar chart?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 2K+ Views

To increase the thickness of error lines in a Matplotlib bar chart, we can use the error_kw parameter with a dictionary containing line width properties. This parameter controls the appearance of error bars including their thickness, cap size, and cap thickness. Basic Bar Chart with Default Error Lines Let's first create a simple bar chart with default error lines ? import matplotlib.pyplot as plt # Sample data labels = ['G1', 'G2', 'G3', 'G4', 'G5'] values = [20, 35, 30, 35, 27] errors = [2, 3, 4, 1, 2] fig, ax = plt.subplots(figsize=(7.5, 3.5)) ...

Read More

How to plot a time series array, with confidence intervals displayed in Python? (Matplotlib)

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 3K+ Views

To plot a time series with confidence intervals in Python, we can use Matplotlib's plot() for the main line and fill_between() for the confidence bands. This visualization helps show data uncertainty and trends over time. Step-by-Step Approach Here's how to create a time series plot with confidence intervals ? Create or load your time series data Calculate rolling mean and standard deviation Define upper and lower confidence bounds Plot the mean line using plot() Add confidence intervals using fill_between() Example import numpy as np import pandas as pd import matplotlib.pyplot as plt ...

Read More

How to plot a watermark image in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 1K+ Views

A watermark is a semi-transparent image overlay that appears on top of your plot. Matplotlib provides the figimage() method to add watermark images directly to figures. Basic Watermark Example Here's how to add a watermark image to a matplotlib plot ? import numpy as np import matplotlib.pyplot as plt from matplotlib import cbook import matplotlib.image as image # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Load sample watermark image with cbook.get_sample_data('logo2.png') as file: watermark = image.imread(file) # Create plot fig, ax = plt.subplots() # ...

Read More

Different X and Y scales in zoomed inset in Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 1K+ Views

To show different X and Y scales in zoomed inset in Matplotlib, we can use the inset_axes() method from mpl_toolkits.axes_grid1.inset_locator. This allows us to create a magnified view of a specific region with custom scaling. Creating a Basic Inset with Different Scales Here's how to create a zoomed inset that focuses on a specific region of your plot ? import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.axes_grid1.inset_locator import mark_inset, inset_axes plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create data points x = np.linspace(0, 1, 100) y = x ** 2 ...

Read More

How to plot y=1/x as a single graph in Python?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 2K+ Views

To plot the function y=1/x as a single graph in Python, we use matplotlib and numpy libraries. The hyperbola y=1/x has two branches separated by asymptotes at x=0 and y=0. Steps to Plot y=1/x Set the figure size and adjust the padding between and around the subplots Create data points using numpy, excluding x=0 to avoid division by zero Plot x and 1/x data points using plot() method Add labels and legend for better visualization Display the figure using show() method Example Here's how to plot the hyperbola y=1/x with proper handling of the ...

Read More

How to change the separation between tick labels and axis labels in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Mar-2026 22K+ Views

In Matplotlib, you can control the spacing between tick labels and axis labels using the labelpad parameter. This parameter adjusts the distance between the axis label and the tick labels, giving you precise control over your plot's appearance. Syntax plt.xlabel("label_text", labelpad=distance) plt.ylabel("label_text", labelpad=distance) The labelpad parameter accepts a numeric value representing the distance in points between the axis label and tick labels. Basic Example Here's how to adjust the separation between tick labels and axis labels ? import matplotlib.pyplot as plt # Set figure size plt.figure(figsize=(8, 5)) # Create ...

Read More
Showing 261–270 of 902 articles
« Prev 1 25 26 27 28 29 91 Next »
Advertisements