Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 使用ggplot翻转条形图上的数字_R_Ggplot2 - Fatal编程技术网

R 使用ggplot翻转条形图上的数字

R 使用ggplot翻转条形图上的数字,r,ggplot2,R,Ggplot2,我使用以下代码创建了一个绘图: p <- ggplot(flexbooks, aes(x=SchoolYear, y=Count,fill=Type)) + geom_bar(stat="identity") + geom_text(data=flexbooks,aes(label=Count),vjust=-1,hjust=0.5) p p尝试反转图例: p <- ggplot(flexbooks, aes(x=SchoolYear, y=Count,fill=Type))

我使用以下代码创建了一个绘图:

p <- ggplot(flexbooks, aes(x=SchoolYear, y=Count,fill=Type)) + geom_bar(stat="identity") +
  geom_text(data=flexbooks,aes(label=Count),vjust=-1,hjust=0.5)
p

p尝试反转图例:

p <- ggplot(flexbooks, aes(x=SchoolYear, y=Count,fill=Type)) +  
     geom_bar(stat="identity") +
     geom_text(data=flexbooks,aes(label=Count),vjust=-1,hjust=0.5) +
     guides(fill = guide_legend(reverse = TRUE))

p您的问题不包含答案。因此,很难理解您的问题并给出适当的答案。请提供您的数据(例如,使用
dput()
)或使用R中的一个示例数据集。此外,请在您的帖子中添加重现问题所需的最少代码。