qqnorm(plotdata$CWRES) qqline(plotdata$CWRES) 坐标轴标签设置
时间: 2023-12-21 16:04:22 浏览: 161
# 设置x轴标签
xlabel <- expression(paste("Theoretical quantiles of ", epsilon[i]))
# 设置y轴标签
ylabel <- expression(paste("CWRES of ", epsilon[i]))
# 绘制Q-Q图并添加坐标轴标签
qqnorm(plotdata$CWRES, xlab = xlabel, ylab = ylabel)
qqline(plotdata$CWRES)
相关问题
ggplot(plotdata,aes(x=RDA1,y=RDA2,color=plotdata$Group))+ geom_point(size=4,aes(color = plotdata$Group,shape=plotdata$Treatment))+ stat_ellipse(aes(fill=plotdata$Group),geom = "polygon",linewidth=0.6,level = 0.95,alpha = 0.1)+ geom_segment(data=RDAE,aes(x = 0, y = 0, xend = RDAE[,1]*3.5, yend = RDAE[,2]*3.5), arrow = arrow(length = unit(0.03, 'npc')),linewidth =1,color="gray2")+ geom_text(data = RDAE,aes(RDA1 * 4,RDA2 * 4,label = rownames(RDAE)),color = 'gray2',size = 4)+ xlab(paste("RDA1 (",rda1,"%",")"))+ylab(paste("RDA2 (",rda2,"%",")"))+ theme_bw(base_line_size = 1.05,base_rect_size = 1.05)+ scale_color_manual(values=c("#3FBDA7","#0172B6","#BD3C29","#F0965D","#BEBADA"))+ scale_shape_manual(values = c(1,2,3))+ theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank())+ geom_hline(aes(yintercept=0), colour="gray45",size=0.8, linetype="dashed")+ geom_vline(aes(xintercept=0), colour="gray45",size=0.8, linetype="dashed") 请修改R脚本,将图例名修改为Bac,同时将填充图例与颜色图例合并表示
可以使用scale_color_manual()函数和scale_fill_manual()函数来修改图例名和合并填充图例与颜色图例。
修改后的代码如下:
ggplot(plotdata,aes(x=RDA1,y=RDA2,color=plotdata$Group, fill=plotdata$Group))+
geom_point(size=4,aes(shape=plotdata$Treatment))+
stat_ellipse(aes(fill=plotdata$Group),geom = "polygon",linewidth=0.6,level = 0.95,alpha = 0.1)+
geom_segment(data=RDAE,aes(x = 0, y = 0, xend = RDAE[,1]*3.5, yend = RDAE[,2]*3.5),
arrow = arrow(length = unit(0.03, 'npc')),linewidth =1,color="gray2")+
geom_text(data = RDAE,aes(RDA1 * 4,RDA2 * 4,label = rownames(RDAE)),color = 'gray2',size = 4)+
xlab(paste("RDA1 (",rda1,"%",")"))+ylab(paste("RDA2 (",rda2,"%",")"))+
theme_bw(base_line_size = 1.05,base_rect_size = 1.05)+
scale_color_manual(name="Bac", values=c("#3FBDA7","#0172B6","#BD3C29","#F0965D","#BEBADA"))+
scale_fill_manual(name="Bac", values=c("#3FBDA7","#0172B6","#BD3C29","#F0965D","#BEBADA"))+
scale_shape_manual(values = c(1,2,3))+
theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank())+
geom_hline(aes(yintercept=0), colour="gray45",size=0.8, linetype="dashed")+
geom_vline(aes(xintercept=0), colour="gray45",size=0.8, linetype="dashed")
机器学习 逻辑回归函数plotData部分核心matlab代码
在Matlab中,逻辑回归函数`plotData`的核心部分通常是用于可视化输入数据和预测结果的。假设我们已经有了特征变量`X`和对应的标签变量`y`,以及训练得到的逻辑回归系数`theta`,这里是一个简单的代码示例:
```matlab
% 定义数据范围
x_min = min(X(:,1)); x_max = max(X(:,1));
y_min = min(y); y_max = max(y);
% 创建网格用于绘图
xx = linspace(x_min, x_max, 100);
yy = linspace(y_min, y_max, 100);
[X,Y] = meshgrid(xx, yy);
Z = sigmoid(dot([XX(:), ones(size(XX,1),1)], theta));
% 网格数据转置,方便绘制
Z = reshape(Z, size(X));
% 绘制数据点和预测边界
figure;
surf(X, Y, Z)
hold on
scatter3(X(:,1), X(:,2), y, 'filled')
xlabel('Feature 1');
ylabel('Feature 2');
zlabel('Probability');
title('Logistic Regression Decision Boundary');
hold off
```
在这个例子中,`sigmoid`函数用于计算逻辑回归的预测概率,`dot`函数用于向量乘法。`meshgrid`生成二维网格,`reshape`将概率数组转化为表面图的格式。最后,数据点和预测边界的图形都被添加到了同一个图表上。
阅读全文