Ich zeichne eine Streudiagramm-Matrix mit ggpairs
. Ich verwende den folgenden Code ein:Wie füge ich eine externe Legende zu ggpairs() hinzu?
# Load required packages
require(GGally)
# Load datasets
data(state)
df <- data.frame(state.x77,
State = state.name,
Abbrev = state.abb,
Region = state.region,
Division = state.division
)
# Create scatterplot matrix
p <- ggpairs(df,
# Columns to include in the matrix
columns = c(3,5,6,7),
# What to include above diagonal
# list(continuous = "points") to mirror
# "blank" to turn off
upper = "blank",
legends=T,
# What to include below diagonal
lower = list(continuous = "points"),
# What to include in the diagonal
diag = list(continuous = "density"),
# How to label inner plots
# internal, none, show
axisLabels = "none",
# Other aes() parameters
colour = "Region",
title = "State Scatterplot Matrix"
)
# Show the plot
print(p)
und ich erhalte die folgende Handlung:
Nun kann man leicht sehen, dass ich Legenden in der Matrix für jedes Grundstück bin immer. Ich möchte nur eine universelle Legende für das ganze Grundstück haben. Wie mache ich das? Jede Hilfe würde sehr geschätzt werden.
Warum ist das 'shiny' getaggt ??? – jlhoward
Das Tag wurde entfernt, danke, dass Sie darauf hingewiesen haben. – Patthebug