contour

R - ggplot2 contour plot

◇◆丶佛笑我妖孽 提交于 2019-12-21 06:07:06
问题 I am trying to replicate the code from Andrew Ng's Machine Learning course on Coursera in R (as the course is in Octave). Basically I have to plot a non linear decision boundary (at p = 0.5) for a polynomial regularized logistic regression. I can easily replicate the plot with the base library: contour(u, v, z, levels = 0) points(x = data$Test1, y = data$Test2) where: u <- v <- seq(-1, 1.5, length.out = 100) and z is a matrix 100x100 with the values of z for every point of the grid. Dimension

Turn hist2d output into contours in matplotlib

*爱你&永不变心* 提交于 2019-12-21 04:53:37
问题 I have generated some data in Python using matplotlib.hist2d. An example of the data is seen below. As you can see this data has some contours in it found by tracing the same color throughout the plot. I see a gamma distribution centered around 0.015. I would like to take this data and gather these contours so I can see a line trace through each color level. I tried playing around with the contour function as here counts, xedges, yedges, Image = hist2d(x, y, bins=bins, norm=LogNorm(), range=[

Hu moments comparison

放肆的年华 提交于 2019-12-21 04:27:12
问题 i tried to compare two images and use Hu moment to compare contour extracted from these images: https://docs.google.com/file/d/0ByS6Z5WRz-h2WHEzNnJucDlRR2s/edit and https://docs.google.com/file/d/0ByS6Z5WRz-h2VnZyVWRRWEFva0k/edit The second image is equal to the first only it's rotated and i expected as result same Humoments. They are a little bit different. Humoments sign on the right (first image): [[ 6.82589151e-01] [ 2.06816713e-01] [ 1.09088295e-01] [ 5.30020870e-03] [ -5.85888607e-05] [

Python matplotlib contour plot logarithmic color scale

南楼画角 提交于 2019-12-21 04:02:20
问题 I have problems with a contour-plot using logarithmic color scaling. I want to specify the levels by hand. Matplotlib, however, draws the color bar in a strange fashion -- the labels are not placed well and only one color appears. The idea is based on http://adversus.110mb.com/?cat=8 Is there anybody out there, who can help me? I use the latest git-repository matplotlib version, v1.1.0 (2011-04-21) import matplotlib.pyplot as plt import numpy as np from matplotlib.mlab import bivariate_normal

Draw axis lines or the origin for Matplotlib contour plot

左心房为你撑大大i 提交于 2019-12-20 11:14:37
问题 I want to draw x=0 and y=0 axis in my contour plot, using a white color. If that is too cumbersome, I would like to have a white dot denoting where the origin is. My contour plot looks as follows and the code to create it is given below. xvec = linspace(-5.,5.,100) X,Y = meshgrid(xvec, xvec) fig = plt.figure(figsize=(6, 4)) contourf(X, Y, W,100) plt.colorbar() 回答1: There are a number of options (E.g. centered spines), but in your case, it's probably simplest to just use axhline and axvline. E

Finding the “fitLine ” of contours in OpenCV

寵の児 提交于 2019-12-20 10:08:42
问题 I'm a program that find contours in a stream, for example : I want to find "set of points " that can describe this contours say like the red line : the yellow part is the the moments of the contours , I tried to use fitLine function of opencv but the result was nonsense, any Idea how can I get the middle line of a contours, that should represent the key aspect of my Contours . by the way **I'm not asking for codes ! ** just a hint how can I do that ? thanks in advance for any help 回答1: maybe

OpenCV - using cv2.approxPolyDP() correctly

穿精又带淫゛_ 提交于 2019-12-20 09:58:22
问题 I am trying to extract an approximation of a contour in an image, using cv2.approxPolyDP() . Here's the image I am using: My code attempts to isolate the main island and define and plot the contour approximation and contour hull. I have plotted the contour found in green, the approximation in red: import numpy as np import cv2 # load image and shrink - it's massive img = cv2.imread('../data/UK.png') img = cv2.resize(img, None,fx=0.25, fy=0.25, interpolation = cv2.INTER_CUBIC) # get a blank

contour is not equal to contour[i]?

吃可爱长大的小学妹 提交于 2019-12-20 07:39:06
问题 This is based from this question, which is focusing more on OpenCV C++ so I decided to make this question. This is one part of my program: vector<vector<Point> > contours; vector<vector<Point> > largest_contours; double largest_area = 0; for(int i= 0; i < contours.size(); i++){ double area = contourArea(contours[i]); if(area >= largest_area){ largest_area = area; largest_contours = contours[i]; <---THIS is the problem } } Basically the program will do: Scans every contours detected in the

Pyplot contour is flipped along xy

半世苍凉 提交于 2019-12-20 07:26:20
问题 I have a lot of data on a scatter graph- the end result will have several million points. This is too many to make sense of on a scatter graph- I want to turn it into a 2D histogram, and plot a contour plot, as described here https://micropore.wordpress.com/2011/10/01/2d-density-plot-or-2d-histogram/ This is similar to the code I'm using, and has the same problem import numpy import matplotlib.pyplot as pyplot def convert_edges_to_centres(edges): centres = numpy.empty(len(edges)-1) for i in

hatch a NaN region in a contourplot in matplotlib

我们两清 提交于 2019-12-20 02:17:51
问题 I am contourplotting a matrix of data. Some of the matrix's elements are NaN's (corresponding to parameter combinations where no solution exists). I would like to indicate this region in the contourplot by a hatched region. Any idea on how to achieve this? 回答1: contourf and contour methods don't draw anything where an array is masked (see here)! So, if you want the NaN elements region of the plot to be hatched, you just have to define the background of the plot as hatched. See this example: