【问题标题】:Change chart values on the graphic axes. Language R更改图形轴上的图表值。语言 R
【发布时间】:2017-10-28 20:38:08
【问题描述】:

我需要更改垂直 y 轴上的图表值。我有这样的数据。

我需要 y 轴上的值像 GNP 一样,从 500 到 3000,而不是从 1 到 20。 这是我绘制图形的代码。

      library(lattice)
      data(Investment, package="sandwich")
      Investment <- as.data.frame(Investment)
      stripplot(Investment$GNP~Investment$Investment|"Graphic", 
      right = F, xlab="Investment", ylab="GNP")

提前谢谢你

【问题讨论】:

    标签: r lattice graphic


    【解决方案1】:

    您应该改用xyplot

    library(lattice)
    data(Investment, package = "sandwich")
    Investment <- as.data.frame(Investment)
    
    xyplot(
      x = GNP ~ Investment | "Graphic",
      data = Investment,
      right = F,
      xlab = "Investment",
      ylab = "GNP"
    )
    

    【讨论】:

    • 谢谢,但是我可以用 stripplot graphics 做这个吗?
    • 你不应该,因为 stripplot 是一个单变量散点图。这意味着它的目的是只绘制一个定量变量,可能被几个因素分开。这就是为什么您的 y 轴数据被视为因素的原因。
    • 好的,请告诉我除了xyplot 之外还有什么其他图形可以用于两个变量?我需要使用六种不同的图形来分析数据。条形图、点图、bwplot 也无法正常工作。
    • 您可以使用来自基本graphicsplot 或来自ggplot2ggplot。这些是我的建议。我猜lattice 包有点麻烦。
    • 我只需要使用 lattice 包中的图形。所以除了xyplot之外别无选择?
    猜你喜欢
    • 1970-01-01
    • 2013-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    • 1970-01-01
    相关资源
    最近更新 更多