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
24
votes
1 answer

Layering a contourf plot and surface_plot in matplotlib

I am struggling with layering and zorder in python. I am making a 3D plot using matplotlib with three relevant elements: A surface_plot of a planet, a surface_plot of rings around that planet, and a contourf image that shows the planet's shadow cast…
ahle6481
  • 723
  • 1
  • 6
  • 10
23
votes
1 answer

How to project filled contour onto a 3d surface plot

I'm simply trying to plot a surface and its contour in 3D, exactly as in this example. This is the code I'm using to do it: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import numpy def…
pceccon
  • 9,379
  • 26
  • 82
  • 158
22
votes
2 answers

How to create a polar contour plot

Update: I've done a full write-up of the way I found to do this on my blog at http://blog.rtwilson.com/producing-polar-contour-plots-with-matplotlib/ - you may want to check there first. I'm trying to plot a polar contour plot in matplotlib. I've…
robintw
  • 27,571
  • 51
  • 138
  • 205
15
votes
4 answers

How can I make an animation with contourf()?

I'm trying to animate the wigner function of the spatial coordinates of some time-dependent data. The wigner function is 2 dimensional, so I'm using contourf() to plot it. I have the data stored in a HDF5 file and can make Wigner distributions on…
Dan
  • 12,157
  • 12
  • 50
  • 84
14
votes
2 answers

Python matplotlib colorbar scientific notation base

I am trying to customise a colorbar on my matpllotlib contourf plots. Whilst I am able to use scientific notation I am trying to change the base of the notation - essentially so that my ticks would be in the range of (-100,100) rather than…
John
  • 143
  • 1
  • 5
9
votes
3 answers

subplots with different colormaps matlab

I am trying to make a graph with two different contourf subplots that use completely different colormaps. However with the code I currently have (which creates a custom colormap for one of the subplots), the subplots come out with the same colormap.…
agold2121
  • 103
  • 1
  • 6
6
votes
2 answers

Update range of colorbar in matplotlib

I want to update a contourf plot within a function, which works fine. However, the range of the data changes and I therefore also have to update the colorbar. That is where I fail to do so. Please see following minimum working example: import…
Sebastian
  • 755
  • 3
  • 7
  • 22
6
votes
3 answers

Matplotlib normalize colorbar (Python)

I'm trying to plot a contourf-plot using matplotlib (and numpy of course). And it works, it plots what it should plot, but unfortunatelly I cannot set the colorbar range. The problem is that I have a plenty of plots and need all of them to have the…
itpdg
  • 316
  • 1
  • 3
  • 10
5
votes
1 answer

Matplotlib projection 3d levels issue

I've got quite strange error which comes from contourf(). I want to set specific min and max values for my 3D projection, however when I'm trying to set something bigger than -+max(Z) I get the error message: File "C:\Program…
Gatto Nou
  • 89
  • 1
  • 12
5
votes
1 answer

Conflict between 'ShowText' and 'LineStyle' in the contourf function in MATLAB R2019a?

I'm using the code as follows. But the figures are different when I run my code in MATLAB R2014a and R2019a (in the same computer, Win7 64bit). It seems there is a conflict between 'ShowText' and 'LineStyle' in function contourf in MATLAB R2019a ?…
JQY
  • 91
  • 3
5
votes
1 answer

matplotlib: assign color to a radius

I have a 3D plot of a disk. Now I would like to plot the surface in color depending on values which are stored in an array. E.g. the radius of the disk is 300mm. The array could like: arr = np.array([[ 114.28, 14], [ 128.57, 16], …
roflcopter122
  • 165
  • 1
  • 14
5
votes
1 answer

contour does not plot specified number of contours

I generate some data within a loop and like to plot them as a contour plot. Each plot should use the same colormap and a specified number of contour levels. Also, the first level color should be white. The figure generated by the following snippet…
DaPhil
  • 1,509
  • 4
  • 25
  • 47
5
votes
1 answer

Matlab: how to set logarithmic scale on the coutour plot

I have some data that I want to display as contour plot with logarithmic scale of the values (the matrix Z) and labelled countours. This is how I do it: [C, h1] = contourf(X, Y, log(Z)); clabel(C,h1); Here is my result: My question is: how can I…
user2738748
  • 1,106
  • 2
  • 19
  • 36
4
votes
0 answers

Plotting in polar space in matplotlib

Consider the following data, which is defined in polar space in theta, r, and is plotted twice; once in the the orthogonal theta-r phase space, and one in cartesian space after an inverse transformation from polar coordinates to x-y (i.e. what…
pretzlstyle
  • 2,774
  • 5
  • 23
  • 40
4
votes
1 answer

Forcing colorbar ticks at min/max values

I am plotting using the contourf function from matplotlib and would like to add a colorbar, I've noticed that sometimes the ticks don't go the max/min values. Is there a clean way to force it to set ticks at these values? Note: Checking the max and…
Morten Nissov
  • 392
  • 3
  • 13
1
2 3
24 25