Questions tagged [contourf]

Filled two-dimensional contour plot

Function Reference

A filled contour plot displays isolines calculated from matrix Z and fills the areas between the isolines using constant colors. The color of the filled areas depends on the current figure's colormap.

contourf(Z) draws a contour plot of matrix Z, where Z is interpreted as heights with respect to a plane. Z must be at least a 2-by-2 matrix. The number of contour lines and the values of the contour lines are chosen automatically.

contourf(Z,n) draws a contour plot of matrix Z with n contour levels.

contourf(Z,v) draws a contour plot of matrix Z with contour levels at the values specified in vector v.

contourf(X,Y,Z), contourf(X,Y,Z,n), and contourf(X,Y,Z,v) produce contour plots of Z using X and Y to determine the x- and y-axis limits. When X and Y are matrices, they must be the same size as Z, in which case they specify a surface as surf does.

[C,h,CF] = contourf(...) returns the contour matrix C as calculated by the function contourc and used by clabel, a vector of handles h to patch graphics objects, and a contour matrix CF for the filled areas.

Documentation: http://nf.nci.org.au/facilities/software/Matlab/techdoc/ref/contourf.html


Function Reference

matplotlib.pyplot.contourf

364 questions
4
votes
3 answers

Why is part of my contour plot showing white?

I am using Python's matplotlib.pyplot.contourf to create a contour plot of my data with a color bar. I have done this successfully countless times, even with other layers of the same variable. However, when the values get small (on the order of…
WVJoe
  • 515
  • 7
  • 21
4
votes
1 answer

2x2 Contourf plots sharing the same colorbar

I would like to add a single color bar on the right side of the following 2x2 plot. import matplotlib.pyplot as plt import numpy as np x = np.linspace(-np.pi*2, np.pi*2, num=50) y = np.linspace(-np.pi*2, np.pi*2, num=50) def fun(x, y, pw1, pw2): …
user1993416
  • 698
  • 1
  • 9
  • 28
4
votes
1 answer

How to overlay contour plot on 3-D surface plot with matplotlib or plotly?

I have a 3-D surface plot that shows x and y coordinates and depths. I also have a 2-D contourf plot with x and y coordinates and the filled contours at the different locations. If I know the depths at the coordinates in the contourf plot, is there…
MAJ
  • 437
  • 5
  • 17
4
votes
1 answer

Colormap three colors

I have a netcdf file with positive and negative currents (upwelling and downwelling respectively). I want to create a contourf where downwelling is green, upwelling is red and 0 is black. So far this is my code including some code from the Mathworks…
Jellyse
  • 839
  • 7
  • 22
4
votes
2 answers

Getting 'ValueError: x and y must be 1D arrays of the same length' when they are in fact 1D arrays of same length

I have this dataframe: key variable value 0 0.25 -0.2 606623.455859 1 0.27 -0.2 621462.029200 2 0.30 -0.2 640299.078053 3 0.33 -0.2 653686.910706 4 0.35 -0.2 659278.593742 5 0.37 -0.2 …
Rushwin Jamdas
  • 344
  • 1
  • 5
  • 18
4
votes
2 answers

Creating a heatmap by sampling and bucketing from a 3D array

I have some experimental data that exists like so: x = array([1, 1.12, 1.109, 2.1, 3, 4.104, 3.1, ...]) y = array([-9, -0.1, -9.2, -8.7, -5, -4, -8.75, ...]) z = array([10, 4, 1, 4, 5, 0, 1, ...]) If it's convenient, we can assume that the data…
Maro K
  • 43
  • 3
4
votes
1 answer

Create a contour plot from 3 vectors

I'm trying to create a contour plot from this data: pH D Tur 5.10 3 79.18918919 5.50 6 92.97297297 5.00 0 50.09009009 5.00 6 90.36036036 5.10 9 91.08108108 5.10 12 89.18918919 5.10 15 83.6036036 5.00 18 …
Daniel Valencia C.
  • 2,159
  • 2
  • 19
  • 38
4
votes
0 answers

matplotlib hatched contourf visibility depends on pdf reader

I'm struggling with the pdf backend of matplotlib and the contourf function. I try to plot forbidden areas on a 2D colored map. The forbidden areas are represented by hatched contourf with transparent (alpha=0.4) black color. the used code is given…
aTben0
  • 314
  • 1
  • 6
4
votes
2 answers

Contourf and quiver Animation with Basemap Python

I have two different datasets with different (lat, lon) grid over a common region. I am trying to plot a contourf of one and quiver of another on a common basemap, and then animate this over time. I have followed this…
user5687103
3
votes
1 answer

What does the levels argument in the contourf mean?

This question is about the matploblib contourf function. (https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.contourf.html) The documentation for the function describes the levels argument as levels : int or array-like, optional If…
Aritra
  • 400
  • 3
  • 10
3
votes
1 answer

pyplot.contourf() returns error when specified levels argument

EDIT: The issue is most likely about the version. The levels argument takes an integer argument in version 3.0.0, while this issue has occurred while using version 2.2.2. UPDATE: The issue didn't occur after installing the version >=3.0.0. I'm…
s-jevtic
  • 51
  • 1
  • 6
3
votes
1 answer

Weather data over maps

I am trying to plot some weather data over a map using Basemap (I'm open to trying cartopy also) on Python. Right now, my weather data looks like this. My data source is basically an array with each position corresponding to a square of the grid and…
3
votes
1 answer

Cannot change hatch density using contourf in Matplotlib 2.2.2

I want to change the density of hatch lines using Matplotlib v2.2.2 and the contourf() function (specifically, I want to increase the density). I have read that you can increase the density of a hatch by increasing how many times you use the hatch…
David M.
  • 381
  • 3
  • 10
3
votes
3 answers

Stop contourf interpolating values

I am trying to plot some 2D values in a Basemap with contourf (matplotlib). However, contourf by default interpolates intermediate values and gives a smoother image of the data. Is there any way to make contourf to stop interpolating between…
Numlet
  • 819
  • 1
  • 9
  • 21
3
votes
0 answers

How to make a contour plot of desired shape with matplotlib

Lets say I want to plot a 2D contour, with a set of points that do not form a rectangle necessarily (a trapezoid for instance, or a quadrilateral element). the shape is defined through a set of points with coordinates (X,Y,Z), in which X and Y…
user3252955
  • 81
  • 1
  • 10
1
2
3
24 25