我正在设计一个包含多个图的图纸,但是对于只有一个条的所有条形图,都不会显示x轴标签。 如何使轴标签显示在所有绘图中?
这是我的结果:
这是我的代码:
library(utils)
library(RColorBrewer)
library(readr)
library(readxl)
rm(list=ls())
color <- brewer.pal(6,"Spectral")
overlap <- read_excel("overlap.xlsx")
par(mar=c(3,3,1,1),mgp=c(2,0.9,0),xaxs="i", yaxs="i")
overlap.dat <- overlap[overlap$`Countries and areas`=="Pakistan",]
overlap.dat <- t(overlap.dat)
colnames(overlap.dat) = overlap.dat[5,]
overlap.dat <- as.matrix(overlap.dat[-c(1:8,14),])
barplot(overlap.dat, main = "Pakistan", col = color, ylim = c(0,100), xlim = c(0, 8),
cex.names = 0.8, names.arg = colnames(overlap.dat), legend = TRUE,
args.legend = list(x = "topright", y = 100, cex = 0.8, bty = "n"), las = 2 )
答案 0 :(得分:0)
但是我已经解决了。问题是r将所有单行数据帧的矩阵都更改为向量。
以下是我如何解决的代码:
.fillna()