English 中文(简体)
{R grid}:如何建立一个以肤色填满的多角半?
原标题:{R grid}: how to create a polygon half filled with color?

(这个问题可能太困难,也许不值得解决——然而,如果解决办法容易——我很想知道)

请允许我说,我树立了一种形象(利用电网包)。

require(grid)
grid.newpage()
grid.polygon(x=c((0:4)/10, rep(.5, 5), (10:6)/10, rep(.5, 5)),
             y=c(rep(.5, 5), (10:6/10), rep(.5, 5), (0:4)/10),
             id=rep(1:5, 4),
             gp=gpar(fill=1:5))

但是,现在,如果我只想部分填充一些多管区(请说一只将填满1/3,另一只填满1/2,另一只填满了彩色)。 因此,它喜欢部分填充的水玻璃。

我认为,在构筑多角时,问题在于,假定我只想根据我给它的比例计算新的多角——如何能够做到这一点。

我提问的动机是想再提供一层关于原地的资料(见包装的SeqLogo功能)

感谢。

问题回答

您可以两倍地填充多角:首先用提纲提一整条,但填满。 你们可以比较容易地看到这一例子。

x <- c(left = 0.25, right = 0.75)
y <- c(bottom = 0.1, mid = 0.6, top = 0.9)

grid.newpage()
grid.polygon(x =  rep(x[c("left", "right", "right", "left")], 2),
             y =  y[rep(c("bottom", "top", "bottom", "mid"), each = 2)],
             id = rep(1:2, each = 4),
             gp = gpar(fill = c(NA, "blue")))




相关问题
Bounding ellipse

I have been given an assignement for a graphics module, one part of which is to calculate the minimum bounding ellipse of a set of arbitrary shapes. The ellipse doesn t have to be axis aligned. This ...

Line segment in a triangle

How can we check if a line segment falls partially or fully inside a triangle? Cheers.

Line Segments from a point

I have a point p, and 2 line segments in a 2D plane. Point p is a location of view from where camera is looking towards the line segments. I want to check if line segment 1 is partially or fully ...

Creating a surface of triangles from a set of 2D points

I have a set of points and I need to convert the set to (non-overlapping) triangles (or a big polygon if equivalent)... The application: I have a list of locations (latitude,longitude) from a country,...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Delete holes in a Polygon

I have a polygon determined by an Array of Points. This polygon is crossing itself making some holes in the polygon itself. My questions is: How can I omit this holes and just get the exterior ...

Finding cycle of 3 nodes ( or triangles) in a graph

I am working with complex networks. I want to find group of nodes which forms a cycle of 3 nodes (or triangles) in a given graph. As my graph contains about million edges, using a simple iterative ...

热门标签