contour

How to plot contours on a map with ggplot2 when data is on an irregular grid?

萝らか妹 提交于 2019-11-29 10:14:13
Sorry for the wall of text, but I explain the question, include the data, and provide some code :) QUESTION: I have some climate data that I want to plot using R. I am working with data that is on an irregular, 277x349 grid, where (x=longitude, y=latitude, z=observation). Say z is a measure of pressure (500 hPa height (m)). I tried to plot contours (or isobars) on top of a map using the package ggplot2, but I am having some trouble due to the structure of the data. The data comes from a regular, evenly spaced out 277x349 grid on a Lambert conformal projection, and for each grid point we have

An Error in R: When I try to apply outer function:

依然范特西╮ 提交于 2019-11-29 09:02:19
Here is my code: Step1: Define a inverse function which I will use later inverse = function (f, lower = -100, upper = 100) { function (y) uniroot((function (x) f(x) - y), lower = lower, upper = upper)[1] } Step2: Here is my functions and their inverse: F1<-function(x,m1,l,s1,s2){l*pnorm((x-m1)/s1)+(1-l)*pnorm((x+m1)/s2)} F1_inverse = inverse(function(x) F1(x,1,0.1,2,1) , -100, 100) F2<-function(x,m2,l,s1,s2){l*pnorm((x-m2)/s1)+(1-l)*pnorm((x+m2)/s2)} F2_inverse = inverse(function(x) F1(x,1,0.1,2,1) , -100, 100) Step3: Here is my final function which combines the above functions (I am sure the

Contour 学习笔记(二):使用级联功能实现蓝绿部署和金丝雀发布

拥有回忆 提交于 2019-11-29 07:42:01
上篇文章 介绍了 Contour 分布式架构的工作原理,顺便简单介绍了下 IngressRoute 的使用方式。本文将探讨 IngressRoute 更高级的用法,其中级联功能是重点。 1. IngressRoute 大入门 上篇文章在 examples/example-workload 目录下创建了一个示例应用,我们来回顾一下它的 IngressRoute 配置: apiVersion: contour.heptio.com/v1beta1 kind: IngressRoute metadata: labels: app: kuard name: kuard namespace: default spec: virtualhost: fqdn: kuard.local routes: - match: / services: - name: kuard port: 80 virtualhost : 该字段是 root IngressRoute,表示此域的顶级入口点。 fqdn : 该字段指定了 完整的域名 ,可以通过在 HTTP 请求头中指定 Host: 字段来访问该服务。 这是最简单是使用方法,看起来没什么特别的,我们来稍作修改一下: apiVersion: contour.heptio.com/v1beta1 kind: IngressRoute metadata:

How to draw a contour plot when data are not on a regular grid?

孤街醉人 提交于 2019-11-29 05:19:34
Say I have 3 variables such that x=1:9 y=c(1,1,1,2,2,2,3,3,3) z=6:14 How can I rearrange the data so that I can make a contour plot of the data with r? I am getting the message Error in contour.default(x, y, z) : increasing 'x' and 'y' values expected Thank you. z is a matrix of values where contour lines are to be drawn. x and y are their respective location. "Tyler" at r-help mailing list explains this and gives an example of how to transform your data to make things work. See also examples in the help of ?contour . x = seq(0, 10, by = 0.5) y = seq(0, 10, by = 0.5) z <- outer(x, y) contour(x

plot multiple 2d contour plots in one 3d figure [Matlab]

孤街浪徒 提交于 2019-11-29 04:52:15
I would like to know how to plot multiple, 2D contour plots spaced apart in the z-axis, in a 3D figure like this: NOTE : The first part of this answer was meant for HG1 graphics. See the second part if you're working with MATLAB R2014b and up ( HG2 ). HG1: The contour function internally creates a number of patch objects, and returns them as a combined hggroup object . So we could set the ZData of all patches by shifting in the Z-dimensions to the desired level (by default contour is shown at z=0). Here is an example: [X,Y,Z] = peaks; surf(X, Y, Z), hold on % plot surface [~,h] = contour(X,Y,Z

opencv find concave hull

匆匆过客 提交于 2019-11-29 04:34:03
I have a set of discrete points shown in an image, like the following I want to reconstruct or up sampling (I'm not sure what's the correct way to describe it) the image, so that the result image would be like the following . It doesn't need to be exactly the same as the example image, but the main idea is to fill up the original one. I have an initial idea about how to do it. But I don't know how to do it after the first step. My idea is to first separate image using kmeans and find out the different objects. And I have successfully done it. The resulting images after kmeans are: . After

How to fill in the contour fully using stat_contour

杀马特。学长 韩版系。学妹 提交于 2019-11-29 01:33:18
I am looking for ways to fully fill in the contour generated by ggplot2's stat_contour. The current result is like this: # Generate data library(ggplot2) library(reshape2) # for melt volcano3d <- melt(volcano) names(volcano3d) <- c("x", "y", "z") v <- ggplot(volcano3d, aes(x, y, z = z)) v + stat_contour(geom="polygon", aes(fill=..level..)) The desired result can be produced by manually modifying the codes as follows. v + stat_contour(geom="polygon", aes(fill=..level..)) + theme(panel.grid=element_blank())+ # delete grid lines scale_x_continuous(limits=c(min(volcano3d$x),max(volcano3d$x)),

Multiple filled.contour plots in one graph using with par(mfrow=c())

坚强是说给别人听的谎言 提交于 2019-11-29 00:14:21
I am trying to construct a graph consisting of 2-3 filled.contour plots next to each other. The color scale is the same for all plots, and I would like only one z value key plot. I am having difficulties to do this with par(mfrow=c(1,3)) Example code: x <- 1:5 y <- 1:5 z <- matrix(outer(x,y,"+"),nrow=5) filled.contour(x,y,z) filled.contour(x,y,z,color.palette=rainbow) z2 <- z z2[5,5] <- Inf filled.contour(x,y,z2,col=rainbow(200),nlevels=200) Is it possible to stack 2-3 of these plots next to each other with only one z value color key? I can do this in GIMP but I was wondering if it is natively

R plot filled.contour() output in ggpplot2

寵の児 提交于 2019-11-29 00:06:57
I want to plot this figure created with filled.contour(), but in ggplot2, how do I do this? I want to use ggplot2 because the graphing conventions are easier. The reason I want to use filled.contour() is because I tried geom_tile() and image.plot() and they both created very tile like outputs, and I need an output similar to filled.contour(). This is my figure: Code: library(akima) df <-read.table("Petra_phytoplankton+POM_xydata_minusNAs_noduplicates.txt",header=T) attach(df) names(df) fld <- with(df, interp(x = longitude, y = latitude, z = d13C)) filled.contour.ungeoreferenced <- (filled

Calculate the area of an object with OpenCV

拥有回忆 提交于 2019-11-28 23:50:58
I need to calculate the area of a blob/an object in a grayscale picture (loading it as Mat, not as IplImage) using OpenCV . I thought it would be a good idea to get the coordinates of the edges (number of edges change form object to object) or to get all coordinates of the contour and then use contourArea() to calculate the area of my object. I deleted all noise and got some nice and satisfying contours by using findContours() (programming in C++ ). findContours(InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy,int mode, int method, Point offset=Point()); Now I got to