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

Plot contours of a given set of points

I have a set of given set of points (x,y, F(x,y)) and I would like to plot a contour plot with (x,y) shown as dots and the contours calculated as level curves of F(x,y). Does anyone know how to do this with seaborn? I would like something like looks…
Pratik C
  • 53
  • 1
  • 6
2
votes
1 answer

Custom made colormap for contourf

I have a 3d function and want to show contours at [0.683 0.9545 0.9973]. I want the area 0->0.683 to be filled with red, 0.683->0.9545 to be blue, 0.9545->0.9973 to be green and 0.9973->1.0 to be white. So basically I have the following: contours =…
user12291
  • 23
  • 2
2
votes
1 answer

Put contour plots of for non-overlapping data ranges on a single set of axes?

I would like to put contour plots of two datasets on the same axes with the same colorbar. The X and Y ranges of the data do not overlap but are physically adjacent. Here's a simplified example of two such contourf plots which I'd like to combine on…
campel
  • 21
  • 1
2
votes
1 answer

Symmetrical Log color scale in matplotlib contourf plot

How do I create a contour plot with a symlog (symmetrical log) scale for the contours. i.e. a log scale that shows both negative and positive values. One possibility would be to work off of this…
Caleb
  • 3,839
  • 7
  • 26
  • 35
2
votes
1 answer

Present different colors in contourf

I want to present a 2D matrix, like in below for example: 2 3 4 5 6 3 1 2 2 4 5 5 1 2 2 2 2 4 I use contourf in matplotlib,to do the work, cmap = colors.ListedColormap(['0.75', (0.2, 0.3, 0.5), 'r', 'b', 'g', 'c']) bounds = [-0.5, 0.5, 1.5, 2.5,…
rankthefirst
  • 1,370
  • 2
  • 14
  • 26
2
votes
1 answer

Avoid overlapping of contour line labels

I have a code like this [Cp hp] = contourf(log2(S_pr),log2(C_pr),ClassRateMatr_pr); clabel(Cp,hp,'LabelSpacing',150,'BackgroundColor',[1 1 1],'fontsize',16); Which gives me this As you can see the labels overlap such a way that it's impossible to…
Rashid
  • 4,326
  • 2
  • 29
  • 54
2
votes
1 answer

How can I get matplotlib to make a colorbar with a color centered on 0?

I'm plotting a Wigner distribution of some data, and at extreme parts of the distribution the value tends to be near 0. It also tends to oscillate a lot, making my test plot look like this: The waves in the blue "sea" have an amplitude around…
Dan
  • 12,157
  • 12
  • 50
  • 84
1
vote
2 answers

How to avoid using zeros in interpolation for contourf, for plotting CFD velocity data

From a CFD simulation in Ansys Fluent, I have a dataframe from a csv containing 4 columns: x,y,z (nodal coordinates of irregular grid), and u (streamwise velocity magnitude). I want to plot a contour plot of u over the x-z plane. The solid body…
lsmontal
  • 11
  • 3
1
vote
0 answers

Number of points within each contours

I have points (x,y) coordinates and I plot them and their density using a kde gaussian estimation, now using contourf i have different colors depending on the density but what i'd like to do is to give in the colorbar or on the plot the number of…
Luigi
  • 13
  • 4
1
vote
0 answers

Unevenly spaced levels with tricontourf and colorbar

I am trying to interpolate & plot some irregularly spaced data as a contour plot. I want to manually set the contour levels to some arbitrary values. The problem I am running into is the colorbar. I want each level to have its own color, but when I…
1
vote
1 answer

ValueError plotting contourf in Cartopy Azimuthal Equidistant map projection

I would like to use contourf in a Cartopy Azimuth Equidistant map projection. For context, I am trying to plot travel time (in h) of a signal across the globe. Roughly, this is somewhat what I am trying my plot to look like: (Image credits to…
1
vote
1 answer

Overlaying contour plot on basemap

Please can anyone look at this code it is not giving a desired result. # use the Miller projection m = Basemap( projection='mill', resolution='i', lon_0=0., lat_0=0.) # draw coastline, map-boundary …
TThoye
  • 25
  • 5
1
vote
2 answers

Dataframe compare, combine and merge for rectangular meshgrid

I have two dataframes shown below: df_1 = Lon Lat N 0 2 1 1 1 2 2 3 2 2 3 1 3 3 2 2 and df_2 = Lon Lat N 0 1.0 1.0 NaN 1 2.0 1.0 NaN 2 3.0 1.0 NaN 3 4.0 1.0 NaN 4 1.0 2.0 NaN 5 2.0 2.0 NaN 6 3.0 2.0…
Feng Hu
  • 63
  • 6
1
vote
1 answer

Pandas groupby and contour plot with NaN

I have a DataFrame in the form of: Lon Lat N 0 2 1 1 1 2 2 2 2 2 3 1 3 2 2 1 4 3 2 1 5 3 2 1 where Lon and Lat represent the coordinates (locations), N represents the count number at corresponding…
Feng Hu
  • 63
  • 6
1
vote
1 answer

Contour plot from a 3D array in Python

I have a [128x128x128] array. From this I need to plot 1 single plane, i.e., the central plane along the z-axis, so I will have to use the array in the form A[:,:,64]. Do you know which commands should I type in order to get this contour plot?