R: How to add legend to a scatter plot with 5 stats differents [duplicate]
This question already has an answer here:
Two geom_points add a legend
2 answers
Plotting two variables as lines using ggplot2 on the same graph
5 answers
I'm newbie in R and I'm trying to make a graphic with ggplot2 where you can 5 different stats. So, I would like to have on the right side a legend with the color and the name of the stadistic but I don't know how to do it.
My code to make the graphic are:
ggplot(object@data, aes(x=data[,1])) +
geom_point(aes(y=data[,2]), color="blue") +
geom_point(aes(y=data[,3]), color = "red") +
geom_point(aes(y=data[,4]), color = "olivedrab4") +
geom_point(aes(y=data[,5]), color = "hotpink4") +
geom_point(aes(y=data[,6]), color = "limegreen") +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com",
x = "Equipos", y = "Total") +
#Pone las etiquetas del eje de las X en vertical
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank()) +
#Modificamos el fondo del panel
theme(panel.background = element_rect(fill = 'peachpuff', colour = 'white')) +
theme(plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
I supposed that with this code I could have the legend but it doesn't work to me :(
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
Right now, what I get is this graphic:
How can I set a legend on the right side with each color and the name of the statistic?
r ggplot2 legend
marked as duplicate by Henrik
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 11:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Two geom_points add a legend
2 answers
Plotting two variables as lines using ggplot2 on the same graph
5 answers
I'm newbie in R and I'm trying to make a graphic with ggplot2 where you can 5 different stats. So, I would like to have on the right side a legend with the color and the name of the stadistic but I don't know how to do it.
My code to make the graphic are:
ggplot(object@data, aes(x=data[,1])) +
geom_point(aes(y=data[,2]), color="blue") +
geom_point(aes(y=data[,3]), color = "red") +
geom_point(aes(y=data[,4]), color = "olivedrab4") +
geom_point(aes(y=data[,5]), color = "hotpink4") +
geom_point(aes(y=data[,6]), color = "limegreen") +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com",
x = "Equipos", y = "Total") +
#Pone las etiquetas del eje de las X en vertical
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank()) +
#Modificamos el fondo del panel
theme(panel.background = element_rect(fill = 'peachpuff', colour = 'white')) +
theme(plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
I supposed that with this code I could have the legend but it doesn't work to me :(
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
Right now, what I get is this graphic:
How can I set a legend on the right side with each color and the name of the statistic?
r ggplot2 legend
marked as duplicate by Henrik
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 11:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You get legends with mapped aesthetics. So map the aesthetics!
– hrbrmstr
Nov 14 '18 at 21:08
How can I do that?
– José Carlos
Nov 14 '18 at 21:10
Please start by reading any basicggplot
tutorial
– Henrik
Nov 14 '18 at 21:12
1
You'll want to first "gather" your plotted columns to move them from 5 separate columns to 2 columns, one saying which one it is (the "key") and one showing the value. Then you feed this to ggplot, where the key is mapped to an aesthetic, like color. Here's an example of those two steps: drsimonj.svbtle.com/plot-some-variables-against-many-others
– Jon Spring
Nov 14 '18 at 21:23
add a comment |
This question already has an answer here:
Two geom_points add a legend
2 answers
Plotting two variables as lines using ggplot2 on the same graph
5 answers
I'm newbie in R and I'm trying to make a graphic with ggplot2 where you can 5 different stats. So, I would like to have on the right side a legend with the color and the name of the stadistic but I don't know how to do it.
My code to make the graphic are:
ggplot(object@data, aes(x=data[,1])) +
geom_point(aes(y=data[,2]), color="blue") +
geom_point(aes(y=data[,3]), color = "red") +
geom_point(aes(y=data[,4]), color = "olivedrab4") +
geom_point(aes(y=data[,5]), color = "hotpink4") +
geom_point(aes(y=data[,6]), color = "limegreen") +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com",
x = "Equipos", y = "Total") +
#Pone las etiquetas del eje de las X en vertical
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank()) +
#Modificamos el fondo del panel
theme(panel.background = element_rect(fill = 'peachpuff', colour = 'white')) +
theme(plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
I supposed that with this code I could have the legend but it doesn't work to me :(
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
Right now, what I get is this graphic:
How can I set a legend on the right side with each color and the name of the statistic?
r ggplot2 legend
This question already has an answer here:
Two geom_points add a legend
2 answers
Plotting two variables as lines using ggplot2 on the same graph
5 answers
I'm newbie in R and I'm trying to make a graphic with ggplot2 where you can 5 different stats. So, I would like to have on the right side a legend with the color and the name of the stadistic but I don't know how to do it.
My code to make the graphic are:
ggplot(object@data, aes(x=data[,1])) +
geom_point(aes(y=data[,2]), color="blue") +
geom_point(aes(y=data[,3]), color = "red") +
geom_point(aes(y=data[,4]), color = "olivedrab4") +
geom_point(aes(y=data[,5]), color = "hotpink4") +
geom_point(aes(y=data[,6]), color = "limegreen") +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com",
x = "Equipos", y = "Total") +
#Pone las etiquetas del eje de las X en vertical
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank()) +
#Modificamos el fondo del panel
theme(panel.background = element_rect(fill = 'peachpuff', colour = 'white')) +
theme(plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
I supposed that with this code I could have the legend but it doesn't work to me :(
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),
values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
Right now, what I get is this graphic:
How can I set a legend on the right side with each color and the name of the statistic?
This question already has an answer here:
Two geom_points add a legend
2 answers
Plotting two variables as lines using ggplot2 on the same graph
5 answers
r ggplot2 legend
r ggplot2 legend
asked Nov 14 '18 at 21:05
José CarlosJosé Carlos
70821947
70821947
marked as duplicate by Henrik
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 11:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Henrik
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 '18 at 11:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You get legends with mapped aesthetics. So map the aesthetics!
– hrbrmstr
Nov 14 '18 at 21:08
How can I do that?
– José Carlos
Nov 14 '18 at 21:10
Please start by reading any basicggplot
tutorial
– Henrik
Nov 14 '18 at 21:12
1
You'll want to first "gather" your plotted columns to move them from 5 separate columns to 2 columns, one saying which one it is (the "key") and one showing the value. Then you feed this to ggplot, where the key is mapped to an aesthetic, like color. Here's an example of those two steps: drsimonj.svbtle.com/plot-some-variables-against-many-others
– Jon Spring
Nov 14 '18 at 21:23
add a comment |
You get legends with mapped aesthetics. So map the aesthetics!
– hrbrmstr
Nov 14 '18 at 21:08
How can I do that?
– José Carlos
Nov 14 '18 at 21:10
Please start by reading any basicggplot
tutorial
– Henrik
Nov 14 '18 at 21:12
1
You'll want to first "gather" your plotted columns to move them from 5 separate columns to 2 columns, one saying which one it is (the "key") and one showing the value. Then you feed this to ggplot, where the key is mapped to an aesthetic, like color. Here's an example of those two steps: drsimonj.svbtle.com/plot-some-variables-against-many-others
– Jon Spring
Nov 14 '18 at 21:23
You get legends with mapped aesthetics. So map the aesthetics!
– hrbrmstr
Nov 14 '18 at 21:08
You get legends with mapped aesthetics. So map the aesthetics!
– hrbrmstr
Nov 14 '18 at 21:08
How can I do that?
– José Carlos
Nov 14 '18 at 21:10
How can I do that?
– José Carlos
Nov 14 '18 at 21:10
Please start by reading any basic
ggplot
tutorial– Henrik
Nov 14 '18 at 21:12
Please start by reading any basic
ggplot
tutorial– Henrik
Nov 14 '18 at 21:12
1
1
You'll want to first "gather" your plotted columns to move them from 5 separate columns to 2 columns, one saying which one it is (the "key") and one showing the value. Then you feed this to ggplot, where the key is mapped to an aesthetic, like color. Here's an example of those two steps: drsimonj.svbtle.com/plot-some-variables-against-many-others
– Jon Spring
Nov 14 '18 at 21:23
You'll want to first "gather" your plotted columns to move them from 5 separate columns to 2 columns, one saying which one it is (the "key") and one showing the value. Then you feed this to ggplot, where the key is mapped to an aesthetic, like color. Here's an example of those two steps: drsimonj.svbtle.com/plot-some-variables-against-many-others
– Jon Spring
Nov 14 '18 at 21:23
add a comment |
1 Answer
1
active
oldest
votes
You can start with these steps.
As stated by @Jon Spring, ggplot2
preferes the long format than the wide format of the data, so first you ought to transform your data, than apply the ggplot2
function.
# you can use this package, to melt the data. You have not given any data, so
# at the bottom of this question, you can see some fake data similar to your:
library(reshape2)
long <- melt(data, id.vars = c("name"))
long
name variable value
1 a col2 2
2 b col2 2
3 c col2 2
4 a col3 3
5 b col3 3
6 c col3 3
7 a col4 4
8 b col4 4
9 c col4 4
10 a col5 5
11 b col5 5
12 c col5 5
13 a col6 6
14 b col6 6
15 c col6 6
Now the plot:
ggplot(long, aes(x=long[,1],y =long[,3], color = long[,2])) +
# here only one geom_point, using the long format
geom_point() +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com", x = "Equipos", y = "Total") +
# you can manage the theme features in only one theme
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank(),
panel.background = element_rect(fill = 'peachpuff', colour = 'white'),
plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white"),
legend.key = element_rect(fill = "transparent", colour = "transparent")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
With data:
data <- data.frame(name = c('a','b','c'),
col2 = c(2,2,2),
col3 = c(3,3,3),
col4 = c(4,4,4),
col5 = c(5,5,5),
col6 = c(6,6,6)
)
1
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can start with these steps.
As stated by @Jon Spring, ggplot2
preferes the long format than the wide format of the data, so first you ought to transform your data, than apply the ggplot2
function.
# you can use this package, to melt the data. You have not given any data, so
# at the bottom of this question, you can see some fake data similar to your:
library(reshape2)
long <- melt(data, id.vars = c("name"))
long
name variable value
1 a col2 2
2 b col2 2
3 c col2 2
4 a col3 3
5 b col3 3
6 c col3 3
7 a col4 4
8 b col4 4
9 c col4 4
10 a col5 5
11 b col5 5
12 c col5 5
13 a col6 6
14 b col6 6
15 c col6 6
Now the plot:
ggplot(long, aes(x=long[,1],y =long[,3], color = long[,2])) +
# here only one geom_point, using the long format
geom_point() +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com", x = "Equipos", y = "Total") +
# you can manage the theme features in only one theme
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank(),
panel.background = element_rect(fill = 'peachpuff', colour = 'white'),
plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white"),
legend.key = element_rect(fill = "transparent", colour = "transparent")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
With data:
data <- data.frame(name = c('a','b','c'),
col2 = c(2,2,2),
col3 = c(3,3,3),
col4 = c(4,4,4),
col5 = c(5,5,5),
col6 = c(6,6,6)
)
1
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
add a comment |
You can start with these steps.
As stated by @Jon Spring, ggplot2
preferes the long format than the wide format of the data, so first you ought to transform your data, than apply the ggplot2
function.
# you can use this package, to melt the data. You have not given any data, so
# at the bottom of this question, you can see some fake data similar to your:
library(reshape2)
long <- melt(data, id.vars = c("name"))
long
name variable value
1 a col2 2
2 b col2 2
3 c col2 2
4 a col3 3
5 b col3 3
6 c col3 3
7 a col4 4
8 b col4 4
9 c col4 4
10 a col5 5
11 b col5 5
12 c col5 5
13 a col6 6
14 b col6 6
15 c col6 6
Now the plot:
ggplot(long, aes(x=long[,1],y =long[,3], color = long[,2])) +
# here only one geom_point, using the long format
geom_point() +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com", x = "Equipos", y = "Total") +
# you can manage the theme features in only one theme
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank(),
panel.background = element_rect(fill = 'peachpuff', colour = 'white'),
plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white"),
legend.key = element_rect(fill = "transparent", colour = "transparent")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
With data:
data <- data.frame(name = c('a','b','c'),
col2 = c(2,2,2),
col3 = c(3,3,3),
col4 = c(4,4,4),
col5 = c(5,5,5),
col6 = c(6,6,6)
)
1
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
add a comment |
You can start with these steps.
As stated by @Jon Spring, ggplot2
preferes the long format than the wide format of the data, so first you ought to transform your data, than apply the ggplot2
function.
# you can use this package, to melt the data. You have not given any data, so
# at the bottom of this question, you can see some fake data similar to your:
library(reshape2)
long <- melt(data, id.vars = c("name"))
long
name variable value
1 a col2 2
2 b col2 2
3 c col2 2
4 a col3 3
5 b col3 3
6 c col3 3
7 a col4 4
8 b col4 4
9 c col4 4
10 a col5 5
11 b col5 5
12 c col5 5
13 a col6 6
14 b col6 6
15 c col6 6
Now the plot:
ggplot(long, aes(x=long[,1],y =long[,3], color = long[,2])) +
# here only one geom_point, using the long format
geom_point() +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com", x = "Equipos", y = "Total") +
# you can manage the theme features in only one theme
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank(),
panel.background = element_rect(fill = 'peachpuff', colour = 'white'),
plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white"),
legend.key = element_rect(fill = "transparent", colour = "transparent")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
With data:
data <- data.frame(name = c('a','b','c'),
col2 = c(2,2,2),
col3 = c(3,3,3),
col4 = c(4,4,4),
col5 = c(5,5,5),
col6 = c(6,6,6)
)
You can start with these steps.
As stated by @Jon Spring, ggplot2
preferes the long format than the wide format of the data, so first you ought to transform your data, than apply the ggplot2
function.
# you can use this package, to melt the data. You have not given any data, so
# at the bottom of this question, you can see some fake data similar to your:
library(reshape2)
long <- melt(data, id.vars = c("name"))
long
name variable value
1 a col2 2
2 b col2 2
3 c col2 2
4 a col3 3
5 b col3 3
6 c col3 3
7 a col4 4
8 b col4 4
9 c col4 4
10 a col5 5
11 b col5 5
12 c col5 5
13 a col6 6
14 b col6 6
15 c col6 6
Now the plot:
ggplot(long, aes(x=long[,1],y =long[,3], color = long[,2])) +
# here only one geom_point, using the long format
geom_point() +
labs(title = "Liga DIA: Comparativas (Liga Regular) - www.basketmetrics.com", x = "Equipos", y = "Total") +
# you can manage the theme features in only one theme
theme(axis.text.x = element_text(angle = 90, hjust = 1, color = "white"),
axis.text.y = element_text(color = "white"),
legend.position = "top", legend.title = element_blank(),
panel.background = element_rect(fill = 'peachpuff', colour = 'white'),
plot.background = element_rect(fill = 'navyblue', colour = 'white'),
plot.title = element_text(size = 20, face = "bold", color = "white"),
axis.title.x = element_text(face = "bold", color = "white"),
axis.title.y = element_text(face = "bold", color = "white"),
legend.key = element_rect(fill = "transparent", colour = "transparent")) +
scale_color_manual(name="Estadísticas", labels = c("ORTG", "DRTG", "Pace", "eFG%", "3P%"),values = c("blue", "red", "olivedrab4", "hotpink4", "limegreen"))
With data:
data <- data.frame(name = c('a','b','c'),
col2 = c(2,2,2),
col3 = c(3,3,3),
col4 = c(4,4,4),
col5 = c(5,5,5),
col6 = c(6,6,6)
)
answered Nov 14 '18 at 21:45
s_ts_t
3,47121031
3,47121031
1
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
add a comment |
1
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
1
1
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
Thank hoy so much @s_t for your answer!!!
– José Carlos
Nov 14 '18 at 21:56
add a comment |
You get legends with mapped aesthetics. So map the aesthetics!
– hrbrmstr
Nov 14 '18 at 21:08
How can I do that?
– José Carlos
Nov 14 '18 at 21:10
Please start by reading any basic
ggplot
tutorial– Henrik
Nov 14 '18 at 21:12
1
You'll want to first "gather" your plotted columns to move them from 5 separate columns to 2 columns, one saying which one it is (the "key") and one showing the value. Then you feed this to ggplot, where the key is mapped to an aesthetic, like color. Here's an example of those two steps: drsimonj.svbtle.com/plot-some-variables-against-many-others
– Jon Spring
Nov 14 '18 at 21:23