将图例添加到条形图中

时间:2018-05-02 17:18:12

标签: r graph

我有一个简单的条形图:

[<AbstractClass; Sealed>]
type AppHolder private () =
    static let processor =
        printfn "Starting..."
        Agent.Start(fun inbox ->
            // ...
        )

    static member HandleAction (action:obj) =
        processor.Post action

如何在条形图中添加图例?

2 个答案:

答案 0 :(得分:0)

尝试使用ggplot。它会自动包含一个图例。

df <- tibble(
  y = 1:5,
  x = letters[1:5]
)
ggplot(df, aes(y = y, x = x)) +
  geom_col(aes(fill = x))

enter image description here

答案 1 :(得分:0)

ggplot仅报告每个国家/地区收集的变量响应的数量,而不报告变量中的级别(这是一个因素)。我已经能够使用baplot函数添加图例并添加

legend("topright", legend = c("Level 1", "Level 2"), fill = c("red", "darkblue"))
相关问题