Data Visualization Articles

Page 31 of 68

How to plot signal in Matplotlib in Python?

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

Signal plotting in Matplotlib involves creating time-series visualizations that show how signal amplitude changes over time. This is essential for analyzing waveforms, noise patterns, and signal processing applications. Basic Signal Plot Let's create a simple sinusoidal signal with noise to demonstrate signal plotting ? import matplotlib.pyplot as plt import numpy as np # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Set random seed for reproducible results np.random.seed(0) # Define sampling parameters dt = 0.01 # sampling interval Fs = 1 / dt # sampling frequency t = ...

Read More

Tweaking axis labels and names orientation for 3D plots in Matplotlib

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

To tweak axis labels and names orientation for 3D plots in Matplotlib, you can customize label positioning, spacing, and appearance. This involves setting up a 3D projection and using specific parameters to control how axis labels are displayed. Steps to Customize 3D Axis Labels Set the figure size and adjust the padding between and around the subplots Create a new figure with a white background Get the current axes with 3D projection Set X, Y and Z axis labels with custom linespacing Plot the data points using plot() method Adjust the axis distance for better visibility Display ...

Read More

Plotting scatter points with clover symbols in Matplotlib

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

To plot scatter points with clover symbols in Matplotlib, we can use the scatter() method with the marker parameter set to r'$\clubsuit$'. This creates a scatter plot where each data point is represented by a clover (club) symbol. Setting Up the Plot First, let's configure the figure and generate some sample data ? import matplotlib.pyplot as plt import numpy as np # Set figure size and layout plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create sample data x = np.arange(0.0, 50.0, 2.0) y = x ** 1.3 + np.random.rand(*x.shape) * 30.0 s = ...

Read More

What's the difference between Matplotlib.pyplot and Matplotlib.figure?

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

The key difference lies in their roles: matplotlib.pyplot provides a MATLAB-like interface for creating plots, while matplotlib.figure represents the actual figure container that holds all plot elements. matplotlib.pyplot The matplotlib.pyplot is a collection of functions that make matplotlib work like MATLAB. Each pyplot function makes some change to a figure: creates a figure, creates a plotting area, plots lines, adds labels, etc. In matplotlib.pyplot, various states are preserved across function calls, so it keeps track of things like the current figure and plotting area, directing plotting functions to the current axes. Example import matplotlib.pyplot ...

Read More

How to pass RGB color values to Python's Matplotlib eventplot?

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

To pass RGB color values to Python's Matplotlib eventplot(), you can specify colors as tuples with red, green, and blue values ranging from 0 to 1. This allows precise control over the color of event lines in your plot. Basic Syntax The RGB color format in matplotlib uses values between 0 and 1 − colors = [(red, green, blue)] # Values between 0 and 1 plt.eventplot(positions, color=colors) Example with Single RGB Color Here's how to create an eventplot with a custom RGB color ? import numpy as np import matplotlib.pyplot ...

Read More

How to embed fonts in PDFs produced by Matplotlib

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

To embed fonts in PDFs produced by Matplotlib, we use plt.rcParams['pdf.fonttype'] = 42. This ensures fonts are embedded as TrueType fonts, making PDFs portable and maintaining consistent appearance across different systems. Setting Font Embedding Parameters The key parameter pdf.fonttype = 42 embeds TrueType fonts directly into the PDF. Alternative value 3 converts fonts to Type 3 fonts, but 42 preserves better quality ? import matplotlib.pyplot as plt # Enable font embedding plt.rcParams['pdf.fonttype'] = 42 plt.rcParams['ps.fonttype'] = 42 # For EPS files too print("Font embedding enabled for PDF export") Font embedding ...

Read More

How to display the count over the bar in Matplotlib histogram?

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

To display the count over the bar in matplotlib histogram, we can iterate each patch and use text() method to place the values over the patches. Steps Set the figure size and adjust the padding between and around the subplots. Make a list of numbers to make a histogram plot. Use hist() method to make histograms. Iterate the patches and calculate the mid-values of each patch and height of the patch to place a text. To display the figure, use show() method. ...

Read More

How to replace auto-labelled relative values by absolute values in Matplotlib?

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

In Matplotlib pie charts, auto-labelled values show percentages by default. To display absolute values instead, we can use a custom autopct function with lambda expressions. Understanding the Problem By default, Matplotlib pie charts show percentages. When you have actual data values like [5, 3, 4, 1], the chart displays percentages (38%, 23%, 31%, 8%) instead of the original values. Solution Using Lambda Function Use autopct=lambda p: '{:.0f}'.format(p * total / 100) to convert percentages back to absolute values ? import matplotlib.pyplot as plt # Configure figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = ...

Read More

How to make simple double head arrows on the axes in Matplotlib?

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

Creating double head arrows on Matplotlib axes helps visualize relationships and measurements between points. You can achieve this using the annotate() method with specific arrow properties. Basic Double Head Arrow Use the annotate() method with arrowstyle="" to create arrows pointing in both directions ? import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.annotate('Double Arrow', xy=(0.1, 0.1), xytext=(0.5, 0.5), arrowprops=dict(arrowstyle='', color='red')) plt.show() Customizing Arrow Properties You can customize the arrow appearance by modifying properties like ...

Read More

How to add legends and title to grouped histograms generated by Pandas? (Matplotlib)

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

To add legends and title to grouped histograms generated by Pandas, we can use the DataFrame's plot() method with kind='hist' and then customize the plot using Matplotlib functions. Basic Grouped Histogram with Title First, let's create a DataFrame and plot a basic grouped histogram with a title ? import matplotlib.pyplot as plt import pandas as pd # Set figure size for better visibility plt.rcParams["figure.figsize"] = [10, 6] # Create sample data df = pd.DataFrame({ 'Math': [85, 92, 78, 88, 95, 82, 90], 'Science': [88, 85, 92, ...

Read More
Showing 301–310 of 680 articles
« Prev 1 29 30 31 32 33 68 Next »
Advertisements