Possible Duplicate:
Equation-driven smoothly shaded concentric shapes
我怎么能够把像我所策划的圈子(使用地块)或 rec子一样的不对称心脏划一?
我也这样说,以便我实际上能够这样做,并且能够把这一点与今后类似的需要结合起来。 我看到了比这更细致的地块,因此,那是站不住脚的。
Possible Duplicate:
Equation-driven smoothly shaded concentric shapes
我怎么能够把像我所策划的圈子(使用地块)或 rec子一样的不对称心脏划一?
我也这样说,以便我实际上能够这样做,并且能够把这一点与今后类似的需要结合起来。 我看到了比这更细致的地块,因此,那是站不住脚的。
这是划出“对称方程式”的一个实例,即对具有共同参数的x和 y两种不同方程式进行配对。 你们可以找到许多共同的 cur子和形状,可以在这种框架内书写。
dat<- data.frame(t=seq(0, 2*pi, by=0.1) )
xhrt <- function(t) 16*sin(t)^3
yhrt <- function(t) 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
dat$y=yhrt(dat$t)
dat$x=xhrt(dat$t)
with(dat, plot(x,y, type="l"))
You also could "heat it up" with using the "fill" capability of the polygon
function:
with(dat, polygon(x,y, col="hotpink"))
如果你只想在不同地点周围进行点火,那么,在阅读<条码>帮助(点)条码>页和使用<条码>后,你可以使用“轮式”:
points(c(10,-10, -15, 15), c(-10, -10, 10, 10), pch=169, font=5)
Windows users may want to see if adding the Cairo package helps gain access to card symbols including "hearts".( When I tested the TestChars function on the WinXP "side" of my MacPro I did not get hearts, and paging through the "special symbols" in MS-Word did not uncover anything. So I did a search of Rhelp and found a recent posting by Ivo Welch. He was reporting a bug, but they look OK on my machine.) Further note... I think the hearts and diamonds codes in his were reversed.
library(Cairo)
clubs <- expression(symbol( 247 ))
hearts <- expression(symbol( 251 ))
diamonds <- expression(symbol( 250 ))
spades <- expression(symbol( 252 ))
csymbols <- c(clubs, hearts, diamonds, spades)
plot( 0, xlim=c(0,5), ylim=c(0,2), type="n" )
clr <- c("black", "red", "red", "black")
for (i in 1:4) {
hline <- function( yloc, ... )
for (i in 1:length(yloc))
lines( c(-1,6), c(yloc[i],yloc[i]), col="gray")
hline(0.9);
hline(1.0);
hline(1.1);
hline(1.2)
text( i, 1, csymbols[i], col=clr[i], cex=5 )
text( i, 0.5, csymbols[i], col=clr[i] ) }
# Also try this
plot(1,1)
text(x=1+0.2*cos(seq(0, 2*pi, by=.5)),
y=1+0.2*sin(seq(0, 2*pi, by=.5)),
expression(symbol( 251 ) ) )
解决对等的参数(允许采用数学格式吗?)
x^2 +(5y/4-sqrt(abs(x))^2 = 1
sqrt(1-x^2) = 5y/4 - sqrt(abs(x))
y = 4/5*(sqrt(1-x^2)+sqrt(abs(x))
MASS::eqscplot(0:1,0:1,type="n",xlim=c(-1,1),ylim=c(-0.8,1.5))
curve(4/5*sqrt(1-x^2)+sqrt(abs(x)),from=-1,to=1,add=TRUE,col=2)
curve(4/5*-sqrt(1-x^2)+sqrt(abs(x)),from=-1,to=1,add=TRUE,col=2)
简单易 ha:
plot(1, 1, pch = "♥", cex = 20, xlab = "", ylab = "", col = "firebrick3")
此处为<代码>ggplot的心脏病:
library(ggplot2)
dat <- data.frame(x=seq(0, 2*pi, length.out=100))
cardioid <- function(x, a=1)a*(1-cos(x))
ggplot(dat, aes(x=x)) + stat_function(fun=cardioid) + coord_polar()
And the heart plot (linked by @BenBolker):
heart <- function(x)2-2*sin(x) + sin(x)*(sqrt(abs(cos(x))))/(sin(x)+1.4)
ggplot(dat, aes(x=x)) + stat_function(fun=heart) + coord_polar(start=-pi/2)
Another option,
xmin <- -5
xmax <- 10
n <- 1e3
xs<-seq(xmin,xmax,length=n)
ys<-seq(xmin,xmax,length=n)
f = function(x, y) (x^2+0.7*y^2-1)^3 - x^2*y^3
zs <- outer(xs,ys,FUN=f)
h <- contourLines(xs,ys,zs,levels=0)
library(txtplot)
with(h[[1]], txtplot(x, y))
+---+-******----+----******-+---+
1.5 + ***** ********** ***** +
1 +** * +
0.5 +** * +
| *** *** |
0 + **** **** +
-0.5 + ***** ***** +
-1 + *********** +
+---+-----+-----*-----+-----+---+
-1 -0.5 0 0.5 1
如果你想成为更多的“成熟”,就会尝试以下几个方面(几年前给帮助):
thong<-function(h = 9){
# set up plot
xrange=c(-15,15)
yrange=c(0,16)
plot(0,xlim=xrange,ylim=yrange,type= n )
# draw outer envelope
yr=seq(yrange[1],yrange[2],len=50)
offsetFn=function(y){2*sin(0+y/3)}
offset=offsetFn(yr)
leftE = function(y){-10-offsetFn(y)}
rightE = function(y){10+offsetFn(y)}
xp=c(leftE(yr),rev(rightE(yr)))
yp=c(yr,rev(yr))
polygon(xp,yp,col="#ffeecc",border=NA)
# feasible region upper limit:
# left and right defined by triple-log function:
xt=seq(0,rightE(h),len=100)
yt=log(1+log(1+log(xt+1)))
yt=yt-min(yt)
yt=h*yt/max(yt)
x=c(leftE(h),rightE(h),rev(xt),-xt)
y=c(h,h,rev(yt),yt)
polygon(x,y,col="red",border=NA)
}
A few more varieties:
我不了解有关R的任何情况,但如果你策划这项职能,你将心中:
x^2+(y-(x^2)^(1/3))^2=1
This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...
since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix ...
I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...
I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...
I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...
I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...
Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...
I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...