Matplotlib Articles

Page 57 of 91

How I can get a Cartesian coordinate system in Matplotlib?

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

To create a Cartesian coordinate system in Matplotlib, you can plot data points on an X-Y plane with proper axes and grid lines. This involves setting up the coordinate system with axes, plotting data points, and customizing the appearance for better visualization. Basic Steps To plot a Cartesian coordinate system in matplotlib, follow these steps ? Initialize variables and create data points for x and y coordinates Plot the points using scatter() method with x and y data points Add grid lines and axis labels for better visualization Display the figure using show() method ...

Read More

Bold font weight for LaTeX axes label in Matplotlib

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

To make bold font weight LaTeX axes labels in Matplotlib, you can use LaTeX formatting with the \bf{} command. This technique allows you to create bold tick labels on both x and y axes. Steps to Create Bold LaTeX Axes Labels Create x and y data points using NumPy Use subplot() method to add a subplot to the current figure Set x and y ticks with data points using set_xticks() and set_yticks() methods Plot the data using plot() method Apply LaTeX formatting with \bf{} for bold font weight in tick labels Display the figure using show() method ...

Read More

Getting empty tick labels before showing a plot in Matplotlib

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

To get empty tick labels before showing a plot in Matplotlib, you can access minor tick labels which are typically empty by default. This is useful when you need to check the state of tick labels or manipulate them programmatically. Steps to Get Empty Tick Labels Create data points for the plot Add a subplot using subplot() method Set major ticks and tick labels using set_xticks() and set_xticklabels() Use get_xticklabels(which='minor') to retrieve empty minor tick labels Display the plot using show() method Example Here's how to get empty tick labels and display them before ...

Read More

Is it possible to plot implicit equations using Matplotlib?

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

Matplotlib does not have direct support for plotting implicit equations, but you can visualize them using contour plots. An implicit equation like x² + y² = 25 can be plotted by creating a grid of points and using the contour() method to find where the equation equals zero. Method 1: Using Contour Plots The most common approach is to rearrange your implicit equation to equal zero and use contour plotting ? import matplotlib.pyplot as plt import numpy as np # Set up the coordinate grid delta = 0.025 x_range = np.arange(-5.0, 5.0, delta) y_range = ...

Read More

Gaussian filtering an image with NaN in Python Matplotlib

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

Gaussian filtering is a common image processing technique that smooths images by applying a Gaussian kernel. However, when an image contains NaN (Not a Number) values, standard Gaussian filtering propagates these NaN values throughout the filtered result, making the entire output matrix NaN. Understanding the Problem When you apply a Gaussian filter to data containing NaN values, the convolution operation spreads these NaN values to neighboring pixels. This happens because any mathematical operation involving NaN returns NaN. Example with NaN Propagation Let's see how NaN values affect Gaussian filtering ? import numpy as np ...

Read More

Setting the aspect ratio of a 3D plot in Matplotlib

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

To set the aspect ratio of a 3D plot in Matplotlib, you can control how the axes are scaled relative to each other. This is particularly useful when you want to ensure proper proportions in your 3D visualizations. Basic Steps The process involves the following steps − Create a new figure using figure() method Get the current axes with projection='3d' Create your 3D data points using NumPy Plot your 3D surface or scatter plot Set the aspect ratio using set_aspect() or set_box_aspect() Optionally adjust viewing angle and save the figure Example Here's how ...

Read More

How to plot data into imshow() with custom colormap in Matplotlib?

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

To plot data into imshow() with custom colormap in Matplotlib, we can create our own colormap from a list of colors and apply it to display 2D data as an image. Creating a Custom Colormap We use ListedColormap to generate a colormap object from a list of colors ? import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap import numpy as np # Set figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create random data data = np.random.rand(5, 5) # Create custom colormap from colors cmap = ListedColormap(['red', 'green', 'blue']) # ...

Read More

How to turn off error bars in Seaborn Bar Plot using Matplotlib?

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

By default, Seaborn bar plots display error bars representing confidence intervals. To turn off these error bars, you can use the ci=None parameter in the barplot() function. Basic Bar Plot with Error Bars First, let's create a basic bar plot that shows error bars by default ? import seaborn as sns import matplotlib.pyplot as plt # Load the Titanic dataset df = sns.load_dataset('titanic') # Create bar plot with default error bars plt.figure(figsize=(8, 5)) sns.barplot(x='class', y='age', hue='survived', data=df) plt.title('Bar Plot with Error Bars (Default)') plt.show() Turning Off Error Bars To remove error ...

Read More

How can one modify the outline color of a node in networkx using Matplotlib?

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

When working with NetworkX graphs in matplotlib, you can modify the outline color of nodes using the set_edgecolor() method on the node collection returned by draw_networkx_nodes(). Basic Example Here's how to create a graph and set red outline color for all nodes − import networkx as nx import matplotlib.pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create a DataFrame with edge information df = pd.DataFrame({'from': ['A', 'B', 'C', 'A'], 'to': ['D', 'A', 'E', 'C']}) # Create graph from DataFrame G = nx.from_pandas_edgelist(df, 'from', 'to') # ...

Read More

How do I change the font size of ticks of matplotlib.pyplot.colorbar.ColorbarBase?

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

To change the font size of ticks in a matplotlib colorbar, you can use the tick_params() method on the colorbar's axis. This allows you to customize the appearance of tick labels including their size. Basic Example Here's how to create a colorbar and modify its tick font size ? import numpy as np import matplotlib.pyplot as plt # Set figure properties plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create random 5x5 data data = np.random.rand(5, 5) # Display data as image with colormap im = plt.imshow(data, interpolation="nearest", cmap="copper") # Create colorbar ...

Read More
Showing 561–570 of 902 articles
« Prev 1 55 56 57 58 59 91 Next »
Advertisements