我在使用ggplotly
周围停止y轴文本与刻度重叠时遇到问题ggplot
.我怎样才能解决这个问题?我试过以下代码:
set.seed(395)
df1<- data.frame(CO2= c(cumsum(rnorm(1*36)), cumsum(rnorm(1*36))),
Group= rep(c("A","B"), each=36),
Segment=rep(seq(1,12),each=36))
plot<-ggplot(df1, aes(CO2, fill = Group)) +
geom_density(alpha = 0.8)+
facet_wrap(~ Segment)+
theme_bw()+
labs(x="CO2", y="density")
#Shouldn't the following work?
pb <- plotly_build(plot)
pb$layout$margin$l <- 200
pb$layout$margin$b <- 100
pb
Run Code Online (Sandbox Code Playgroud) 我有一堆充满点的培养皿,我想在Matlab中算一下.这可以可靠地分批完成吗?
例如,该板有352个菌落
我已经尝试过ImageJ,但是需要做很多的边界裁剪并得到可变的结果.
你有什么建议吗?
我想从子目录递归导入文件(不同长度)并将它们放入一个data.frame中,其中一列包含子目录名称,另一列包含文件名(减去扩展名):
e.g. folder structure
IsolatedData
00
tap-4.out
cl_pressure.out
15
tap-4.out
cl_pressure.out
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有:
setwd("~/Documents/IsolatedData")
l <- list.files(pattern = ".out$",recursive = TRUE)
p <- bind_rows(lapply(1:length(l), function(i) {chars <- strsplit(l[i], "/");
cbind(data.frame(Pressure = read.table(l[i],header = FALSE,skip=2, nrow =length(readLines(l[i])))),
Angle = chars[[1]][1], Location = chars[[1]][1])}), .id = "id")
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,说第43行没有2个元素.
还看到这个使用dplyr看起来整洁但我无法让它工作:http://www.machinegurning.com/rstats/map_df/
tbl <-
list.files(recursive=T,pattern=".out$")%>%
map_df(~data_frame(x=.x),.id="id")
Run Code Online (Sandbox Code Playgroud) 我有一个 jsfiddle 代码来记录单击图像的时间和位置。它在任何桌面平台上都可以正常工作,但滚动和突出显示文本块在 chrome 或 safari 中的 iPad 上不起作用。因此,作为一种解决方法,我希望能够复制 javascript 生成但不确定如何复制的点击次数和时间列表。任何想法将不胜感激。
<!-- Image Map Generated by http://www.image-map.net/ -->
<img src="https://hecoira.leeds.ac.uk/wp-content/uploads/sites/164/2019/08/0D174AF3-1221-42A4-878E-305FD6D829BF-e1564773811882.jpeg" usemap="#image-map">
<map name="image-map">
<area target="" alt="IVStand" title="IVStand" href="javascript:ClickOnImageMap('IVStand');" coords="147,258,186,208" shape="rect">
<area target="" alt="Chair" title="Chair" href="javascript:ClickOnImageMap('chair');" coords="68,262,163,343" shape="rect">
<area target="" alt="DoorHandle" title="DoorHandle" href="javascript:ClickOnImageMap('DoorHandle');" coords="17,237,62,371" shape="rect">
<area target="" alt="Bed" title="Bed" href="javascript:ClickOnImageMap('Bed');" coords="176,154,327,224" shape="rect">
<area target="" alt="Window" title="Window" href="javascript:ClickOnImageMap('Window');" coords="159,119,43,8" shape="rect">
<area target="" alt="Trolley" title="Trolley" href="javascript:ClickOnImageMap('Trolley');" coords="53,129,138,162" shape="rect">
<area target="" alt="Sink" title="Sink" href="javascript:ClickOnImageMap('Sink');" coords="503,328,410,284" shape="rect">
<area target="" alt="ClinicalWaste" title="ClinicalWaste" href="javascript:ClickOnImageMap('ClinicalWaste');" coords="297,327,406,374" shape="rect"> …
Run Code Online (Sandbox Code Playgroud) 我有3个向量:Y=rand(1000,1)
,X=Y-rand(1000,1)
和ACTid=randi(6,1000,1)
.我想用Y和X组创建对应于它们的组值1:6(来自ACTid)的箱形图.
这是特别的,看起来很讨厌
for ii=
dummyY(ii)={Y(ACTid==ii)};
dummyX(ii)={X(ACTid==ii)}
end
Run Code Online (Sandbox Code Playgroud)
现在我将数据放在一个单元格中,但无法解决如何在箱线图中对其进行分组的问题.有什么想法吗?
我发现这个aboxplot
功能看起来像这样,但我不想这样,我想要内置的boxplot功能,因为我将它转换为matlab2tikz而且这个功能并不好.
编辑
感谢Oleg:我们现在有一个分组的箱形图......但标签都是偏斜的.
xylabel = repmat({'Bleh','Blah'},1000,1); % need a legend instead, but doesn't appear possible
boxplot([Y(:,end); cfu], {repmat(ACTid,2,1), xylabel(:)} ,'factorgap',10,'color','rk')
set(gca,'xtick',1.5:3.2:50)
set(gca,'xticklabel',{'Direct care','Housekeeping','Mealtimes','Medication','Miscellaneous','Personal care'})
>> ylabel('Raw CFU counts (Y)')
Run Code Online (Sandbox Code Playgroud)
如何添加图例?
我有一个随着时间推移接触表面的data.frame。我只想为每个AcvitivityID附加最后一行的副本:
head(movsdf.rbind)
ActivityID CareType HCWType Orientation Surface Date Time Dev.Date.Time SurfaceCategories
1 01 IV RN01 leftFacing AlcOutside 2019-08-03 11:08:01 2019-08-03 11:08:01 HygieneArea
2 01 IV RN01 leftFacing In 2019-08-03 11:08:12 2019-08-03 11:08:12 In
3 01 IV RN01 leftFacing Door 2019-08-03 11:08:12 2019-08-03 11:08:12 FarPatient
4 02 IV RN01 leftFacing Door 2019-08-03 11:08:18 2019-08-03 11:08:18 FarPatient
5 02 IV RN01 leftFacing Other 2019-08-03 11:08:22 2019-08-03 11:08:22 FarPatient
6 03 IV RN01 leftFacing Table 2019-08-03 11:10:26 2019-08-03 11:10:26 NearPatient
Run Code Online (Sandbox Code Playgroud)
示例数据:
movsdf.rbind<-data.frame(ActivityID=rep(1:4, each=10),Surface=rep(c("In","Table","Out"),each=10)) …
Run Code Online (Sandbox Code Playgroud) 我有一个细胞:
BED4{6,4,4}=[];
eg. BED4{1}{1}{1}
ans =
[8x1 double] [8x1 double] [8x2 double] [8x1 double]
Run Code Online (Sandbox Code Playgroud)
我想计算mean
好像是通过红色箭头的for循环:
到目前为止,我不得不这样做......
figure('color',[1 1 1])
titles={'Direct care','Housekeeping','Mealtimes','Medication rounds','Miscellaneous care','Personal care'};
for care=1:6
subplot(3,2,care)
clear a m e pci1 pci2 gn
for position=1:4
for patient=1:4
a(:,:,position,patient,care)=cell2mat(BED4{care}{position}{patient});
end
end
m=mean(mean(a(:,1,:,:,care),4),3);
e=mean(mean(a(:,2,:,:,care),4),3);
pci1=mean(mean(a(:,3,:,:,care),4),3);
pci2=mean(mean(a(:,4,:,:,care),4),3);
gn=a(:,5,1,1,care);
if care==1
b={m,e,pci1,pci2,gn}; %store for posterity
end
h=errorbar(gn,m,e,'sr');
set(h,'linestyle','--','LineWidth',2,...
'MarkerEdgeColor','k',...
'MarkerFaceColor','white',...
'MarkerSize',5);
ylabel('Relative Risk ');
xlabel('Patient contact count');
title(titles{ii})
set(gca,'xtick',0:2:8)
axis([-2 8 0 1])
end
Run Code Online (Sandbox Code Playgroud)
这使:
我有一个自己制作的可怕的嵌套列表结构,如下所示:
str(CMaster)
List of 4
$ :List of 6
..$ :List of 5
.. ..$ :List of 15
.. .. ..$ : num [1, 1:14] 0.144 0.2 0.256 0.352 0.446 ...
.. .. ..$ : num [1, 1:47] 0.144 0.2 0.375 0.54 0.694 ...
etc
$ :List of 6
..$ :List of 1
.. ..$ :List of 15
.. .. ..$ : num [1, 1:14] 0.144 0.2 0.256 0.352 0.446 ...
.. .. ..$ : num [1, 1:47] 0.144 0.2 …
Run Code Online (Sandbox Code Playgroud) 我有两个配对值的向量
size(X)=1e4 x 1; size(Y)=1e4 x 1
Run Code Online (Sandbox Code Playgroud)
是否有可能contour plot
通过最高密度的点来绘制某种轮廓?即最高聚类=红色,然后在其他地方渐变颜色?
如果您需要更多说明,请询问.问候,
示例数据:
X=[53 58 62 56 72 63 65 57 52 56 52 70 54 54 59 58 71 66 55 56];
Y=[40 33 35 37 33 36 32 36 35 33 41 35 37 31 40 41 34 33 34 37 ];
scatter(X,Y,'ro');
Run Code Online (Sandbox Code Playgroud)
谢谢大家的帮助.还记得我们可以使用hist3
:
x={0:0.38/4:0.38}; % # How many bins in x direction
y={0:0.65/7:0.65}; % # How many bins in y direction
ncount=hist3([X Y],'Edges',[x y]);
pcolor(ncount./sum(sum(ncount))); …
Run Code Online (Sandbox Code Playgroud) 我无法在r中设置轴范围。我的数据在x轴上的值只有2到9,但我希望它的值从1到10。
head(SS)
Phase Bed Site ACC X.M.SA
1 1 1 1 NG NO
2 1 1 2 NG NO
3 1 1 3 SG NO
4 1 1 4 SG NO
5 1 1 5 SG NO
6 1 2 1 SG NO
XMSA<-factor(SS$X.M.SA)
ACC<-factor(SS$ACC,ordered = TRUE,levels=c("NG","SG","LG","MG","HG"))
boxplot(ACC[XMSA=="MSSA"]~SS$Bed[XMSA=="MSSA"],
xlab="Bed",ylab="Growth",
las=1, yaxt="n",ylim=c(1,5),xlim=c(1,10))
axis(2, at=c(1,2,3,4,5),labels=c("NG","SG","LG","MG","HG"),las=1)
Run Code Online (Sandbox Code Playgroud)