绘图

R绘图:

setwd("D:\\Program Files\\R\\data")  #设置图的工作区间


data<-read.delim("test.txt");names(data);   #读取数据源

 

m<-paste(levels(data$年月)[1],levels(data$年月)[length(levels(data$年月))],sep="~");  #取时间轴的区间

 

 t<-paste(m,"年月",sep=" ");    #连接时间轴区间和“年月”这两个字符串

 

y<-paste("价格,币别为:",levels(data$币别),sep=" ");    #连接两个字符串

 

coplot(data$金额~data$年月|data$Product_ID,ylim=c(min(data$金额),max(data$金额)),xlab=t,ylab=y,cex=1.5)    #绘制图形,不同的productId下 的横轴为年月,纵轴为金额的图

 

关于coplot():

函数格式如下:

coplot(formula, data, given.values, panel = points, rows, columns,       show.given = TRUE, col = par("fg"), pch = par("pch"),        bar.bg = c(num = gray(0.8), fac = gray(0.95)),       xlab = c(x.name, paste("Given :", a.name)),       ylab = c(y.name, paste("Given :", b.name)),       subscripts = FALSE,       axlabels = function(f) abbreviate(levels(f)),       number = 6, overlap = 0.5, xlim, ylim, ...) co.intervals(x, number = 6, overlap = 0.5)

 

 

 

formula

a formula describing the form of conditioning plot. A formula of the form y ~ x | a indicates that plots of y versus x should be produced conditional on the variable a. A formula of the form y ~ x| a * b indicates that plots of y versus x should be produced conditional on the two variables a and b.

All three or four variables may be either numeric or factors. When x or y are factors, the result is almost as if as.numeric() was applied, whereas for factor a or b, the conditioning (and its graphics if show.given is true) are adapted.

data

a data frame containing values for any variables in the formula. By default the environment where coplot was called from is used.

given.values

a value or list of two values which determine how the conditioning on a and b is to take place.

When there is no b (i.e., conditioning only on a), usually this is a matrix with two columns each row of which gives an interval, to be conditioned on, but is can also be a single vector of numbers or a set of factor levels (if the variable being conditioned on is a factor). In this case (no b), the result of co.intervals can be used directly as given.values argument.

panel

a function(x, y, col, pch, ...) which gives the action to be carried out in each panel of the display. The default is points.

rows

the panels of the plot are laid out in a rows by columns array. rows gives the number of rows in the array.

columns

the number of columns in the panel layout array.

show.given

logical (possibly of length 2 for 2 conditioning variables): should conditioning plots be shown for the corresponding conditioning variables (default TRUE).

col

a vector of colors to be used to plot the points. If too short, the values are recycled.

pch

a vector of plotting symbols or characters. If too short, the values are recycled.

bar.bg

a named vector with components "num" and "fac" giving the background colors for the (shingle) bars, for numeric and factor conditioning variables respectively.

xlab

character; labels to use for the x axis and the first conditioning variable. If only one label is given, it is used for the x axis and the default label is used for the conditioning variable.

ylab

character; labels to use for the y axis and any second conditioning variable.

subscripts

logical: if true the panel function is given an additional (third) argument subscripts giving the subscripts of the data passed to that panel.

axlabels

function for creating axis (tick) labels when x or y are factors.

number

integer; the number of conditioning intervals, for a and b, possibly of length 2. It is only used if the corresponding conditioning variable is not a factor.

overlap

numeric < 1; the fraction of overlap of the conditioning variables, possibly of length 2 for x and y direction. When overlap < 0, there will be gaps between the data slices.

xlim

the range for the x axis.

ylim

the range for the y axis.

...

additional arguments to the panel function.

x

a numeric vector.

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值