GGPLOT2 3D条形图 [英] ggplot2 3D Bar Plot

查看:1897
本文介绍了GGPLOT2 3D条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这听起​​来很简单,但是有一个一直在寻找字面上一个多小时,现在都没有成功。我只是想要绘制三维条形图中的'R'使用'GGPLOT2'包。我的数据框看起来是这样的:

I Know this sounds basic, but have a been searching for literally more than an hour now without success. I'm simply trying to plot a 3D bar plot in 'R' using the 'ggplot2' package. My dataframe looks something like this:

 x   y     z
t1   5   high
t1   2   low
t1   4   med
t2   8   high
t2   1   low
t2   3   med
t3  50   high
t3  12   med
t3  35   low

和我想绘制这样的事情就可以了:

and I want to plot something like this on it:

任何帮助超过AP preciated !!

Any help is more than appreciated!!

推荐答案

正如评论,3D绘图通常不是一个好的选择(当其他选项),因为它们往往给数据的失真/模糊看法

As mentioned in comments, 3D plots usually aren't a good choice (when other options are available) since they tend to give a distorted/obscured view of data.

这是说,这里是根据需要与 latticeExtra 如何绘制你的数据:

That said, here's how you can plot your data as desired with latticeExtra:

d <- read.table(text=' x   y     z
t1   5   high
t1   2   low
t1   4   med
t2   8   high
t2   1   low
t2   3   med
t3  50   high
t3  12   med
t3  35   low', header=TRUE)

library(latticeExtra)

cloud(y~x+z, d, panel.3d.cloud=panel.3dbars, col.facet='grey', 
      xbase=0.4, ybase=0.4, scales=list(arrows=FALSE, col=1), 
      par.settings = list(axis.line = list(col = "transparent")))

这篇关于GGPLOT2 3D条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆