Data Visualization Articles

Page 9 of 68

How to remove the axis tick marks on a Seaborn heatmap?

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

To remove the axis tick marks on a Seaborn heatmap, you can use the tick_params() method to customize the appearance of ticks and tick labels. This is useful when you want a cleaner visualization without the small lines indicating tick positions. Basic Heatmap with Tick Marks First, let's create a basic heatmap to see the default tick marks − import numpy as np import seaborn as sns import matplotlib.pyplot as plt # Create sample data data = np.random.rand(4, 4) # Create heatmap plt.figure(figsize=(6, 4)) ax = sns.heatmap(data, annot=True, cmap='viridis') plt.title('Heatmap with Default Tick Marks') ...

Read More

Make logically shading region for a curve in matplotlib

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

To make logically shading region for a curve in matplotlib, we can use BrokenBarHCollection.span_where() to create conditional shading based on the curve's values. This technique is useful for highlighting regions where a function satisfies certain conditions. Steps Set the figure size and adjust the padding between and around the subplots. Create t, s1 and s2 data points using numpy. Create a figure and a set of subplots. Plot t and s1 data points; add a horizontal line across the axis. Create a collection of horizontal bars spanning yrange with a sequence of xranges. Add a Collection to ...

Read More

Saving a 3D-plot in a PDF 3D with Python

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

To save a 3D plot in a PDF with Python, you can use matplotlib's savefig() method. This approach creates standard 2D PDF files containing the 3D visualization, which is suitable for most documentation and sharing purposes. Steps Set the figure size and adjust the padding between and around the subplots. Create a new figure or activate an existing figure. Add an 'ax' to the figure as part of a subplot arrangement with 3D projection. Create u, v, x, y and z data points using numpy. Plot a 3D wireframe or surface. Set the title and labels of ...

Read More

How to control the border of a bar patch in matplotlib?

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

In matplotlib, you can control the appearance of bar chart borders using several parameters in the bar() method. The main parameters are edgecolor for border color and linewidth for border thickness. Basic Border Control Use edgecolor to set the border color of bar patches ? import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True heights = [3, 12, 5, 18, 45] labels = ('P1', 'P2', 'P3', 'P4', 'P5') x_pos = np.arange(len(labels)) plt.bar(x_pos, heights, color=(0.9, 0.7, 0.1, 0.5), edgecolor='green') plt.xticks(x_pos, labels) plt.title('Bar Chart with Green Borders') plt.show() ...

Read More

How to increase the line thickness of a Seaborn Line?

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

To increase the line thickness of a Seaborn line plot, you can use the linewidth parameter (or its shorthand lw) in the lineplot() function. This parameter controls how thick the line appears in your visualization. Basic Example Here's how to create a line plot with increased thickness ? import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np # Create sample data df = pd.DataFrame({ 'time': list(pd.date_range("2021-01-01 12:00:00", periods=10)), 'speed': np.linspace(1, 10, 10) }) # Create line plot with thick ...

Read More

How can I plot two different spaced time series on one same plot in Python Matplotlib?

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

When working with time series data, you often need to plot multiple datasets with different time intervals on the same chart. Matplotlib provides excellent tools for handling datetime data and creating professional time series visualizations. Steps to Plot Multiple Time Series Set the figure size and adjust the padding between and around the subplots. Create x1, y1 and x2, y2 data points with different time intervals. Create a figure and a set of subplots. Plot both time series using plot_date() method with different markers and line styles. Format the X-axis ticklabels using DateFormatter. Rotate xtick labels for ...

Read More

How to increase colormap/linewidth quality in streamplot Matplotlib?

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

To increase colormap and linewidth quality in matplotlib streamplot, you need to adjust density, linewidth, and colormap parameters for better visual appearance. Basic Streamplot Setup First, let's create a basic streamplot with improved quality settings ? import numpy as np import matplotlib.pyplot as plt # Set figure size for better display plt.rcParams["figure.figsize"] = [10, 6] plt.rcParams["figure.autolayout"] = True # Create coordinate grid x, y = np.meshgrid(np.linspace(-5, 5, 20), np.linspace(-5, 5, 20)) # Define vector field components X = y Y = 3 * x - 4 * y # Create streamplot with ...

Read More

How to adjust the space between Matplotlib/Seaborn subplots for multi-plot layouts?

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

When creating multi-plot layouts with Matplotlib and Seaborn, controlling the spacing between subplots is essential for professional-looking visualizations. Python provides several methods to adjust subplot spacing effectively. Using subplots_adjust() Method The most common approach is using subplots_adjust() to control horizontal and vertical spacing between subplots. import seaborn as sns import matplotlib.pyplot as plt import numpy as np # Create sample data np.random.seed(42) data1 = np.random.normal(0, 1, 100) data2 = np.random.normal(2, 1.5, 100) data3 = np.random.normal(-1, 0.8, 100) data4 = np.random.normal(1, 1.2, 100) # Set figure size plt.figure(figsize=(10, 6)) # Create subplots fig, axes ...

Read More

How to change the transparency/opaqueness of a Matplotlib Table?

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

In Matplotlib, you can control the transparency (alpha value) of table cells to create visually appealing tables. The set_alpha() method allows you to adjust opacity, where 0.0 is completely transparent and 1.0 is completely opaque. Steps to Change Table Transparency Set the figure size and adjust the padding between and around the subplots. Create a figure and a set of subplots. Create a random dataset with 10×3 dimension. Create a tuple of columns. Get rid of the axis markers using axis('off'). Create a table with data and columns. Iterate each cell of the table and change its ...

Read More

How to sort a boxplot by the median values in Pandas?

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

To sort a boxplot by the median values in Pandas, you need to calculate the median of each group, sort them, and reorder the data accordingly. This technique is useful when you want to display boxplots in a meaningful order based on their central tendency. Steps Create a DataFrame with categorical data Group the data by the categorical variable Calculate the median for each group Sort the medians in desired order Reorder the DataFrame columns based on sorted medians Create the boxplot with sorted data Example Here's how to create a boxplot sorted by ...

Read More
Showing 81–90 of 680 articles
« Prev 1 7 8 9 10 11 68 Next »
Advertisements