【问题标题】:Reverse Y Axis labeling order in Lattice Plots格子图中的反转 Y 轴标记顺序
【发布时间】:2014-08-20 00:00:51
【问题描述】:

我想做一个 xyplot 并且我有学校的名称和他们的分数。学校名称在 y 轴上,他们的分数在 x 轴上。格子图按字母顺序从下到上。我希望它从上到下从 A 到 Z。所以如果我有一个非常小的例子:

x <- sample(1:50,100,T)
y <- as.factor(sample(letters,100,T))
xyplot(y~x)

我怎样才能从上到下从 A 到 Z。我试过rev()sort() 似乎无法改变。我在数据文件中的分组变量是字符,所以不知道如何反转数字。有什么建议吗?

【问题讨论】:

    标签: r graphics plot lattice


    【解决方案1】:

    因子按其级别的顺序打印出来。只需翻转关卡

    x <- sample(1:50,100,T)
    y <- as.factor(sample(letters,100,T))
    y <- factor(y, levels=rev(levels(y)))
    xyplot(y~x)
    

    【讨论】:

      猜你喜欢
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多