Skip to content
Learn Netverks

Lesson

Step 23/36 64% through track

meshgrid

Meshgrid and coordinate grids

Last reviewed Jun 1, 2026 Content v20260601
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches Meshgrid and coordinate grids: NumPy ndarray operations, vectorization, and numerical patterns used across the Python scientific stack.

Teams apply Meshgrid and coordinate grids in every serious NumPy project—skipping it leaves blind spots in analysis and reviews.

You will apply Meshgrid and coordinate grids in contexts like: Notebooks, feature engineering pipelines, and custom numerical code.

Read the narrative, run `import numpy as np` snippets in the playground (install NumPy with pip if the runner lacks it), tweak shapes and dtypes, and complete MCQs.

When you can explain the previous lesson's ideas in your own words.

np.meshgrid and np.mgrid / np.ogrid build coordinate arrays for evaluating functions over 2D grids—common in plotting and PDE-style computations.

meshgrid basics

import numpy as np
x = np.array([0, 1, 2])
y = np.array([0, 10, 20])
X, Y = np.meshgrid(x, y)
print(X.shape, Y.shape)

Evaluating functions

import numpy as np
x = np.linspace(-1, 1, 3)
y = np.linspace(-1, 1, 3)
X, Y = np.meshgrid(x, y)
Z = X**2 + Y**2
print(Z)

ogrid for memory

np.ogrid[0:5, 0:5] returns open grids that broadcast without full dense coordinate arrays—handy for large domains.

Important interview questions and answers

  1. Q: meshgrid indexing='ij'?
    A: Matrix indexing (row, col) vs default 'xy' Cartesian plotting convention.
  2. Q: Used in Matplotlib?
    A: contourf and pcolormesh accept X, Y coordinate grids from meshgrid.

Self-check

  1. Create 2D grid from x=[0,1] and y=[0,10].
  2. Compute Z = X + Y on a small meshgrid.

Tip: Use ogrid for large domains to save memory.

Interview prep

Purpose?

Build coordinate grids for evaluating f(x,y) or plotting.

ogrid?

Open grid—broadcast-friendly, memory efficient.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • meshgrid vs ogrid?
  • Plotting use?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump