Articles on Trending Technologies

Technical articles with clear explanations and examples

How do I apply some function to a Python meshgrid?

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

A meshgrid creates coordinate matrices from coordinate vectors, allowing you to apply functions across all combinations of input values. Python's NumPy provides efficient ways to apply functions to meshgrids using vectorization. Basic Function Application with Lists You can apply functions to coordinate vectors using NumPy's vectorize decorator ? import numpy as np @np.vectorize def foo(a, b): return a + b x = [0.0, 0.5, 1.0] y = [0.0, 1.0, 8.0] print("Function Output:", foo(x, y)) Function Output: [0. 1.5 9. ] Creating and Using Meshgrids ...

Read More

How can I plot a single point in Matplotlib Python?

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

To plot a single data point in matplotlib, you can use the plot() method with specific marker parameters. This is useful for highlighting specific coordinates or creating scatter-like visualizations with individual points. Basic Single Point Plot Here's how to plot a single point with customized appearance ? import matplotlib.pyplot as plt # Define single point coordinates x = [4] y = [3] # Set axis limits and add grid plt.xlim(0, 5) plt.ylim(0, 5) plt.grid(True) # Plot the single point plt.plot(x, y, marker="o", markersize=15, ...

Read More

How to normalize a histogram in Python?

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

To normalize a histogram in Python, we can use the hist() method with the density=True parameter. In a normalized histogram, the area underneath the plot equals 1, making it useful for probability distributions and comparisons. What is Histogram Normalization? Histogram normalization scales the bars so that the total area under the histogram equals 1. This converts frequency counts into probability densities, making it easier to compare datasets of different sizes. Basic Normalization Example Here's how to create a normalized histogram using matplotlib − import matplotlib.pyplot as plt import numpy as np # Sample ...

Read More

How to plot a 3D density map in Python with Matplotlib?

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

A 3D density map visualizes data density across a 2D plane using colors to represent values at different coordinates. Python's Matplotlib provides the pcolormesh() function to create these density maps efficiently. Steps to Create a 3D Density Map To plot a 3D density map in Python with matplotlib, we can take the following steps: Create coordinate data using numpy.linspace() to generate evenly spaced points Generate coordinate matrices using meshgrid() from the coordinate vectors Create density data using mathematical functions (like exponential functions) Plot the ...

Read More

How to show an Axes Subplot in Python?

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

To show an axes subplot in Python, we can use the show() method from matplotlib. This method displays the figure window and renders all the plots that have been created. When multiple subplots are created, show() displays them together in a single window. Basic Subplot Display Steps Import matplotlib.pyplot and numpy Create x and y data points using numpy Plot x and y using plot() method To display the figure, use show() method Example from matplotlib import pyplot as plt ...

Read More

Drawing multiple figures in parallel in Python with Matplotlib

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

To draw multiple figures in parallel in Python with Matplotlib, we can create subplots within a single figure window. This technique allows you to display multiple visualizations side by side for easy comparison. Steps to Create Multiple Subplots Create random data using numpy Add subplots to the current figure using subplot(nrows, ncols, index) Display data as an image using imshow() with different colormaps Use show() to display the complete figure Example Here's how to create four subplots in a single row, each ...

Read More

Extract csv file specific columns to list in Python

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

To extract specific columns from a CSV file into a list in Python, we can use Pandas read_csv() method with the usecols parameter. This allows us to select only the columns we need, making our data processing more efficient. Steps to Extract Specific Columns Create a list of column names that need to be extracted Use read_csv() method with usecols parameter to extract specific columns Convert the extracted columns to lists if needed Process or visualize the extracted data Basic Column Extraction ...

Read More

How to make a log histogram in Python?

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

To make a log histogram in Python, we can use log=True in the argument of the hist() method. This creates a histogram where the y-axis is displayed on a logarithmic scale, which is useful for data with wide ranges or exponential distributions. What is a Log Histogram? A log histogram displays the frequency counts on a logarithmic scale instead of a linear scale. This is particularly useful when your data spans several orders of magnitude or when you want to visualize the distribution of exponentially distributed data more clearly. Basic Log Histogram Here's how to create ...

Read More

How can I display an image using cv2 in Python?

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

To display an image using cv2 in Python, we need to follow a sequence of steps: load the image, display it in a window, wait for user input, and clean up the resources. Steps to Display an Image Load an image from a file using cv2.imread() Display the image in a specified window using cv2.imshow() Wait for a key press using cv2.waitKey() Destroy all HighGUI windows using cv2.destroyAllWindows() Example Here's a complete example that demonstrates how to display an image ? ...

Read More

Save figure as file from iPython notebook using Matplotlib

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

To save a figure as a file from iPython notebook using Matplotlib, we can use the savefig() method. This method allows you to export plots in various formats like PNG, PDF, SVG, and more. Basic Steps To save a figure as a file from iPython, we can take the following steps − Create a new figure or activate an existing figure Add an axes to the figure using add_axes() method Plot the data Save the plot using savefig() method Example Here's ...

Read More
Showing 1–10 of 61,303 articles
« Prev 1 2 3 4 5 6131 Next »
Advertisements