Current location - Trademark Inquiry Complete Network - Overdue credit card - How to draw a multivariate scatter plot using R language
How to draw a multivariate scatter plot using R language

Give you some code, you can study it slowly:

install.packages('ggplot2')

library(ggplot2)

ggplot(a)+geom_bar(aes(x1,y,fill/col=x1/x2),position='dodge',stat='summary',fun='sum'/'mean')bar chart+theme( text = element_text(family='Kai'))

ggplot(a)+geom_boxplot(aes(x1,y,col=x1/x2))box plot

ggplot( a)+geom_point(aes(x1,y,col=x1/x2),position=position_jitter(width=0.04)) scatter plot

1+geom_point(aes(x1,y,col=x1 /x2),stat='summary',fun='sum'/'mean')+scatter

2+geom_line(aes(x1,y,group=1/x2,col=x1/ x2),stat='summary',fun='sum'/'mean')+polyline

3+geom_errorbar(aes(x=x1,ymin=y-se,ymax=y+se, col=x1/x2),position=position_dodge(0.9),width=0.2)+error bar

4+geom_text(aes(x1,y,label=marker,col=x1/x2),position =position_dodge(0.9)vjust=2 or y+2)+significant letters

ggplot(a,aes(x1,y,fill/col=x1/x2))+geom_bar(position='dodge' ,stat='summary',fun='sum'/'mean')+geom_errorbar(aes(ymin=y-se,ymax=y+se),position=position_dodge(0.9),width=0.2)+geom_text(aes (label=marker), position=position_dodge(0.9),vjust=-2) bar chart + error bar + significant letters (just write the coordinates once)

ggplot(a,aes(x1,y ,col=x1/x2))+geom_point(position=position_jitter(width=0.04),stat='summary',fun='sum'/'mean')+geom_line(aes(group=1/x2),stat= 'summary',fun='sum'/'mean')+geom_errorbar(aes(ymin=y-se,ymax=y+se),position=position_dodge(0.9),width=0.2)+geom_text(aes(label= marker), position=position_dodge(0.9),vjust=-2) scatter plot + broken line + error bar + significant letters (just write the coordinates once)

+geom_density(aes(y=liqi)) Density map (1 numerical type)

+geom_area(aes(x=tan,y=liqi)) Area map (2 numerical types)

+geom_smooth(aes(x =tan,y=liqi,group/col=chong),f

ormula=y~x,method='lm',se=F) fitting diagram, grouping/line color (2 numerical types)

+facet_wrap(~riqi,ncol/nrow=2,labeller ='label_both/value') Facet chart, number of facets in each row or column, facet title

+xlab('Independent variable 1 (unit)')+ylab('Dependent variable (unit) )')+scale_fill_discrete(name='independent variable 2') change the axis and legend name +coord_cartesian(ylim= c(0,80)) limit the axis range

(fill=x1/x2, there is this i.e. change color)+scale_fill_manual(values ??= c('grey70', 'grey50', 'grey30')) change the bar fill color (number of colors = number of groups)

(col=x1/x2, With this, you can change the color)+scale_color_manual(values ??= c('red', 'orange', 'yellow')) change the color (number of colors = number of groups)