我需要重复以下事情: tiny pie charts to represent each point in an scatterplot using ggplot2但我偶然发现了ggsubplot包不适用于3.3.1 R版本的问题。
基本上我需要在散点图上的预定义点中使用直方图或饼图。以下是引用帖子中使用的相同代码:
foo <- data.frame(X=runif(30),Y=runif(30),A=runif(30),B=runif(30),C=runif(30))
foo.m <- melt(foo, id.vars=c("X","Y"))
ggplot(foo.m, aes(X,Y))+geom_point()
ggplot(foo.m) +
geom_subplot2d(aes(x = X, y = Y, subplot = geom_bar(aes(variable,
value, fill = variable), stat = "identity")), width = rel(.5), ref = NULL)
代码使用了库reshape2,ggplot2和ggsubplot。
我想看的图片是in the post cited above
UPD:我下载了旧版本的R(3.0.2和3.0.3)和checkpoint包,并使用了:
checkpoint("2014-09-18")
如下面的评论所述。但是我收到了一个错误:
Using binwidth 0.0946
Using binwidth 0.0554
Error in layout_base(data, vars, drop = drop) :
At least one layer must contain all variables used for facetting
我无法解决这个问题,因为当我尝试包含facet时,会出现以下错误:
Error: ggsubplots do not support facetting
答案 0 :(得分:0)
path="xx" #Location of all input files.
cat1 = ascii.read(path + file3, guess=False)
data2 = fits.getdata(path+file2, 1)
cat2 = Table(data2)
cat3 = Table.read(path + 'xyz.tbl', format='ipac')
for i in range(len(cat1)):
(ra1,dec1,flux1,flux1error,maj1,minor1,ang1)= (cat1['RA_Degrees'][i],
cat1['DEC_Degrees'][i],cat1['fitted_total_flux'][i],
cat1['fitted_total_flux_error'][i],cat1['BMajor_Degrees'][i],
cat1['BMinor_Degrees'][i],cat1['position_angle_deg'][i])
ang1=ang1*np.pi/180
for j in range(len(cat2)):
(ra2,dec2,total_cat2,total_error_cat2,maj2,min2,pa2)= (cat2['ra'][j],cat2['dec'][j],
cat2['total'][j],cat2['total_err'][j],
cat2['BMajor'][j],cat2['Bminor'][j],cat2['Position Angle'][j]
for k in range(len(cat3)):
(ra3,dec3,total_cat2,total_error_cat2,maj3,min3,pa3)=(cat3['ra'][k],
cat3['dec'][k],cat3['flux'][k],cat3['ferr'][k],cat3['bmaj'][k],
cat3['bmin'][k],cat3['pa'][k])
if np.all(
np.all(np.abs(ra2-ra1)< maj1+ maj2 and
np.all(np.abs(dec2-dec1)< maj1 + maj2) and
np.all(np.abs(ra3-ra2)< maj2 + maj3) and
np.all(np.abs(dec3-dec2)< maj2 + maj3) and
np.all(np.abs(ra3-ra1)< maj1 + maj3) and
np.all(np.abs(dec3-dec1)< maj1 + maj3)
):
似乎不会很快修复自己。一种选择是使用checkpoint package,并基本上将您的R副本“重置”到包兼容的时间。 This post建议使用2014-09-18的时间点。