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 All three or four variables may be either numeric or factors. When |
data | a data frame containing values for any variables in the formula. By default the environment where |
given.values | a value or list of two values which determine how the conditioning on When there is no |
panel | a |
rows | the panels of the plot are laid out in a |
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 |
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 |
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 |
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 |
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. |