Matplotlib Articles

Page 68 of 91

How to make several plots on a single page using matplotlib in Python?

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

Matplotlib provides several methods to create multiple plots on a single page. You can use subplots() to create a grid of subplots or subplot() to add plots one by one. This is useful for comparing different datasets or showing related visualizations together. Method 1: Using subplots() with Multiple Axes The subplots() function creates a figure with multiple subplot areas in a grid layout − import matplotlib.pyplot as plt import numpy as np # Sample data x = np.linspace(0, 10, 100) y1 = np.sin(x) y2 = np.cos(x) y3 = np.tan(x) y4 = np.log(x + 1) ...

Read More

Scatter plot and Color mapping in Python

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

We can create scatter plots with color mapping using Matplotlib's scatter() method. This technique allows us to visualize an additional dimension of data through color variations, making patterns and relationships more apparent. Basic Scatter Plot with Color Mapping Here's how to create a scatter plot where each point has a different color based on its position in the dataset − import matplotlib.pyplot as plt import numpy as np # Generate random data points x = np.random.rand(100) y = np.random.rand(100) # Create scatter plot with color mapping colors = range(100) plt.scatter(x, y, c=colors, cmap='viridis') plt.colorbar() ...

Read More

How to plot two dotted lines and set marker using Matplotlib?

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 2K+ Views

In this article, we will learn how to plot two dotted lines with custom markers using Matplotlib. Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Prerequisites First, we need to import the matplotlib.pyplot module ? import matplotlib.pyplot as plt Pyplot is a collection of command-style functions that make matplotlib work like MATLAB, providing an easy interface for plotting. Basic Example with Dotted Lines Let's start with a simple example plotting two dotted lines ? import matplotlib.pyplot as plt # Define coordinates for two ...

Read More

How to maximize a plt.show() window using Python?

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

To maximize a matplotlib plot window, you can use the figure manager's built-in methods. The most common approach is using plt.get_current_fig_manager() along with full_screen_toggle() or window.state() methods. Method 1: Using full_screen_toggle() This method toggles the window to full screen mode ? import matplotlib.pyplot as plt plt.subplot(1, 1, 1) plt.pie([1, 2, 3], labels=['A', 'B', 'C']) plt.title('Sample Pie Chart') mng = plt.get_current_fig_manager() mng.full_screen_toggle() plt.show() Method 2: Using window.state() (Tkinter backend) For Tkinter backend, you can maximize the window using the state method ? import matplotlib.pyplot as plt plt.subplot(1, 1, 1) ...

Read More

How to make two plots side-by-side using Python?

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

When creating data visualizations, you often need to display multiple plots side-by-side for comparison. Python's Matplotlib provides the subplot() method to divide a figure into multiple sections and place plots in specific positions. Using plt.subplot() Method The subplot(nrows, ncols, index) method splits a figure into a grid of nrows × ncols sections. The index parameter specifies which section to use for the current plot ? from matplotlib import pyplot as plt import numpy as np # Create sample data x_points = np.array([2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) y1_points = np.array([12, 14, ...

Read More

Saving images in Python at a very high quality

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

To save images in Python with very high quality, you need to control the image format and resolution. The most effective approach is using matplotlib's savefig() method with optimized parameters. Steps for High-Quality Image Saving Create fig and ax variables using subplots() method, where default nrows and ncols are 1. Plot the data using plot() method. Add axes labels using ylabel() and xlabel(). Use vector formats like .eps, .pdf, or .svg for scalable quality. Increase the DPI (dots per inch) value for ...

Read More

Matplotlib legends in subplot

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Oct-2023 29K+ Views

To add legends in a subplot, we can take the following Steps −Using numpy, create points for x, y1, y2 and y3.Create a figure and a set of subplots, using the subplots() method, considering 3 subplots.Plot the curve on all the subplots(3), with different labels, colors. To place the legend for each curve or subplot adding label.To activate label for each curve, use the legend() method.To display the figure, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 100) y1 = np.sin(x) y2 = np.cos(x) y3 ...

Read More

How to plot multiple graphs in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 22-Oct-2023 22K+ Views

To plot multiple graphs in matplotlib, we will use the following steps −StepsCreate x, y1 and y2 data points using numpy.Add a subplot to the current figure at index 1.Plot curve 1 using x and y1.Add a subplot to the current figure at index 2.Plot curve 2 using x and y2.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 10) y1 = np.sin(x) y2 = np.cos(x) plt.subplot(211) plt.plot(y1) plt.subplot(212) plt.plot(y2) plt.show()Output

Read More

How to change the color of the axis, ticks and labels for a plot in matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 07-Oct-2023 42K+ Views

We can change the color of the axis, ticks and labels, using ax.spines['left'].set_color('red') and ax.spines['top'].set_color('red') statements. To change the color of the axis, ticks, and labels for a plot in matplotlib, we can take the following steps −Create a new figure, or activate an existing figure, using plt.figure().Add an axis to the figure as part of a subplot arrangement, using plt.add_subplot(xyz) where x is nrows, y is ncols and z is the index. Here taking x = 1(rows), y = 2(columns) and z = 1(position).Set up X-axis and Y-axis labels using set_xlabel and set_ylabel method for creating ax using add_subplot().To ...

Read More

Data Pre-Processing with Sklearn using Standard and Minmax scaler

Someswar Pal
Someswar Pal
Updated on 05-Oct-2023 666 Views

Introduction Data pre-processing is required for producing trustworthy analytical results. Data preparation includes eliminating duplicates, identifying and fixing outliers, normalizing measurements, and filing away categories of information. Popular for its ability to scale features, handle missing data, and encode categorical variables, the Python-based Sklearn toolkit is an essential resource for pre-processing data. With Sklearn, preprocessing data is a breeze, and you have access to trustworthy methodologies for effective data analysis. Data Pre-Processing Techniques Standard Scaling Data can be transformed using standard scaling so that it is normally distributed around zero and one. It ensures that everything is uniform in size. This ...

Read More
Showing 671–680 of 902 articles
« Prev 1 66 67 68 69 70 91 Next »
Advertisements