Back
Close

Computing with Data

elgeish
106.6K views

Contour Plots

The function contourf displays z = f(x, y) as a function of x, y, quantizing the z values into several constant values. The code below shows how to use contourf to display a contour plot of z = 3 * x ^ 2 + 5 * y ^ 2:

import matplotlib.pyplot as plt
import numpy as np
def f(x, y):
return 3 * x ** 2 + 5 * y ** 2
x_grid = np.linspace(-2, 2, 100)
y_grid = np.linspace(-2, 2, 100)
# Create two ndarrays xx, yy containing x and y coordinates
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants