Data Visualization Articles

Page 15 of 68

How to get coordinates from the contour in matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 6K+ Views

To get coordinates from the contour in matplotlib, you can extract the vertices from the contour paths. This is useful for analyzing contour lines or exporting contour data for further processing. Basic Contour Coordinate Extraction Here's how to create a contour plot and extract its coordinates ? import matplotlib.pyplot as plt import numpy as np # Set figure size plt.rcParams["figure.figsize"] = [8, 6] plt.rcParams["figure.autolayout"] = True # Create sample data x = [1, 2, 3, 4] y = [1, 2, 3, 4] z = [[15, 14, 13, 12], ...

Read More

How to remove random unwanted space in LaTeX-style maths in matplotlib plot?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 10K+ Views

LaTeX ignores the spaces you type and uses spacing the way it's done in mathematics texts. When working with matplotlib's LaTeX rendering, you might encounter unwanted spacing that can be controlled using specific commands. LaTeX Spacing Commands You can use the following four commands to control spacing in mathematical expressions ? \; − thick space \: − medium space \, − thin space \! − negative thin space (reduces spacing) Removing Unwanted Space To remove random unwanted space in LaTeX-style maths in matplotlib plots, use \! which creates a negative thin space, effectively ...

Read More

How to get pixel coordinates for Matplotlib-generated scatterplot?

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

When working with matplotlib scatterplots, you might need to convert data coordinates to pixel coordinates for UI interactions or precise positioning. This can be achieved using matplotlib's coordinate transformation system. Understanding Coordinate Systems Matplotlib uses different coordinate systems − Data coordinates − The actual x, y values of your data points Pixel coordinates − Screen/display coordinates in pixels Transform objects − Convert between coordinate systems Getting Pixel Coordinates from Scatterplot Here's how to extract pixel coordinates from a matplotlib scatterplot ? import numpy as np import matplotlib.pyplot as plt # ...

Read More

How to animate text in Matplotlib?

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

Text animation in Matplotlib allows you to create dynamic visual effects by changing text properties over time. This is useful for presentations, data storytelling, and creating engaging visualizations. Basic Text Animation Setup To animate text in matplotlib, we need to import the animation module and set up a figure with an axes object. The animation works by repeatedly calling a function that modifies text properties. Example Here's how to create an animated text that changes color and size over time − from matplotlib import animation import matplotlib.pyplot as plt # Set figure size ...

Read More

How to make a grouped boxplot graph in matplotlib?

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

A grouped boxplot displays the distribution of a continuous variable across different categories, with each group subdivided by another categorical variable. In matplotlib, we can create grouped boxplots using Seaborn, which provides a high-level interface for statistical visualizations. Basic Grouped Boxplot Here's how to create a grouped boxplot using the tips dataset ? import seaborn as sns import matplotlib.pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Load the tips dataset data = sns.load_dataset('tips') # Create a grouped boxplot sns.boxplot(x='day', y='total_bill', hue='sex', data=data) # Add ...

Read More

How to plot a rainbow cricle in matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 946 Views

To plot a rainbow circle in Matplotlib, we can create concentric circles with different colors representing the colors of a rainbow. This creates a beautiful visual effect with nested circles in rainbow colors. Steps to Create a Rainbow Circle Set the figure size and adjust the padding between and around the subplots Create a figure and a set of subplots Set the X and Y axes to equal scale for perfect circles Define a list of rainbow colors Create concentric circles with decreasing radius Add each circle to the axes with different colors Display the figure using ...

Read More

How to plot thousands of circles quickly in Matplotlib?

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

When plotting thousands of circles in Matplotlib, using individual Circle patches becomes very slow. The efficient approach is to use CircleCollection from matplotlib.collections, which renders all circles in a single operation. Why Use CircleCollection? CircleCollection is optimized for rendering many similar shapes at once. Instead of creating thousands of individual patches, it handles all circles as a single collection, dramatically improving performance. Basic Implementation import numpy as np import matplotlib.pyplot as plt import matplotlib.collections as mc # Generate random data for 1000 circles num_circles = 1000 sizes = 50 * np.random.random(num_circles) positions = 10 ...

Read More

How to plot a time series graph using Seaborn or Plotly?

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

Time series graphs help visualize data changes over time. Seaborn and Plotly are powerful Python libraries that make creating time series plots straightforward and visually appealing. Using Seaborn for Time Series Plot Seaborn's lineplot() function creates clean time series visualizations with minimal code ? import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np # Set figure size plt.rcParams["figure.figsize"] = [10, 6] plt.rcParams["figure.autolayout"] = True # Create sample time series data df = pd.DataFrame({ 'time': pd.date_range("2021-01-01 12:00:00", periods=10, freq="30min"), 'speed': ...

Read More

How to make a rug plot in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 915 Views

A rug plot is a one-dimensional visualization that displays data points as marks along an axis, making it easy to see the distribution and density of values. In Matplotlib, rug plots are often combined with density curves to provide a comprehensive view of data distribution. Basic Rug Plot Let's start with a simple rug plot using sample data points ? import numpy as np import matplotlib.pyplot as plt # Sample data points data = np.array([-6, -4, 2, 1, 4], dtype=np.float) # Create figure and axis fig, ax = plt.subplots(figsize=(8, 4)) # Create rug ...

Read More

How to fill rainbow color under a curve in Python Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 804 Views

Creating a rainbow gradient effect under a curve in Matplotlib involves using the fill_between() function with multiple color layers. This technique creates visually appealing plots by stacking colored regions with slightly different y-offsets. Basic Rainbow Fill Implementation The key is to plot multiple fill_between() layers, each with a different color and y-offset ? import numpy as np import matplotlib.pyplot as plt def plot_rainbow_under_curve(): rainbow_colors = ['violet', 'indigo', 'blue', 'green', 'yellow', 'orange', 'red'] x = np.linspace(-5, 5, 100) y = x ** 2 ...

Read More
Showing 141–150 of 680 articles
« Prev 1 13 14 15 16 17 68 Next »
Advertisements