legend

ggplot2 - How to add unique legend for multiple plots with grid.arrange?

天大地大妈咪最大 提交于 2021-02-07 08:12:37
问题 I have a plot with 4 panels inside made with ggplot2 and grid.arrange . Each of the panel has a legend which is the same for all of them. How can I remove the 4 legends and create a unique one at the bottom of the plot? Here my sample data and plot: set.seed(100) df_1 = data.frame(lat = rnorm(20), lon = rnorm(20), cor = c(rep('positive', 7), rep('negative', 13)), sign = c(rep(99, 5), rep(95, 6), rep(90,9))) lst_df = list(df_1, df_1, df_1, df_1) library(ggplot2) library(gridExtra) library(grid

ggplot2 - How to add unique legend for multiple plots with grid.arrange?

我是研究僧i 提交于 2021-02-07 08:12:37
问题 I have a plot with 4 panels inside made with ggplot2 and grid.arrange . Each of the panel has a legend which is the same for all of them. How can I remove the 4 legends and create a unique one at the bottom of the plot? Here my sample data and plot: set.seed(100) df_1 = data.frame(lat = rnorm(20), lon = rnorm(20), cor = c(rep('positive', 7), rep('negative', 13)), sign = c(rep(99, 5), rep(95, 6), rep(90,9))) lst_df = list(df_1, df_1, df_1, df_1) library(ggplot2) library(gridExtra) library(grid

ggplot2 - How to add unique legend for multiple plots with grid.arrange?

痞子三分冷 提交于 2021-02-07 08:11:34
问题 I have a plot with 4 panels inside made with ggplot2 and grid.arrange . Each of the panel has a legend which is the same for all of them. How can I remove the 4 legends and create a unique one at the bottom of the plot? Here my sample data and plot: set.seed(100) df_1 = data.frame(lat = rnorm(20), lon = rnorm(20), cor = c(rep('positive', 7), rep('negative', 13)), sign = c(rep(99, 5), rep(95, 6), rep(90,9))) lst_df = list(df_1, df_1, df_1, df_1) library(ggplot2) library(gridExtra) library(grid

gnuplot: legend gets hidden behind data

泪湿孤枕 提交于 2021-02-07 02:49:36
问题 I am new to gnuplot and while plotting stacked histogram, I find that legend gets hidden behind the data. Is there a method to put the legend above the data? Thanks a lot for your help. EDIT: I am currently using set key outside bottom to place legend outside, but that is not the best solution I would like. 回答1: Recent versions allow to make the background of the legend white: set key opaque This simply adds a white background to the legend so it appears on top of all graphs. Found the answer

gnuplot: legend gets hidden behind data

随声附和 提交于 2021-02-07 02:49:33
问题 I am new to gnuplot and while plotting stacked histogram, I find that legend gets hidden behind the data. Is there a method to put the legend above the data? Thanks a lot for your help. EDIT: I am currently using set key outside bottom to place legend outside, but that is not the best solution I would like. 回答1: Recent versions allow to make the background of the legend white: set key opaque This simply adds a white background to the legend so it appears on top of all graphs. Found the answer

How to insert a legend in a GGPLOT with multiple time series

巧了我就是萌 提交于 2021-02-05 09:31:03
问题 I'm trying to plot multiple times series on a single graph with GGPLOT . The data set is a Data Frame with the dates in date format on the first column, named Time , and the times series on the other columns, named V1, V2...etc.. I tried: gg1=ggplot() + geom_line(data=PCA2, aes(x=Time, y=V2, group=1), lwd=1.1, color="red") + geom_line(data=PCA2, aes(x=Time, y=V3, group=1), lwd=1.1, color="blue")+ scale_color_discrete(name = "PCA series", labels = c("V2", "V3")) print(gg1) but I just get this

How to insert a legend in a GGPLOT with multiple time series

和自甴很熟 提交于 2021-02-05 09:29:47
问题 I'm trying to plot multiple times series on a single graph with GGPLOT . The data set is a Data Frame with the dates in date format on the first column, named Time , and the times series on the other columns, named V1, V2...etc.. I tried: gg1=ggplot() + geom_line(data=PCA2, aes(x=Time, y=V2, group=1), lwd=1.1, color="red") + geom_line(data=PCA2, aes(x=Time, y=V3, group=1), lwd=1.1, color="blue")+ scale_color_discrete(name = "PCA series", labels = c("V2", "V3")) print(gg1) but I just get this

Change color graphic bar

老子叫甜甜 提交于 2021-02-05 09:28:16
问题 I have two datasets of data printed on the same graph. What I want is to differentiate the information by putting a legend that indicates the color of each of the two pieces of information in the graph. I have not been able to put a different color to each information and also a legend that shows what data each color belongs to. My code: . . . %grafica de barras 1 bar(app.CasosUIAxes,data1.dateRep,data1.cases,'r') %grafica de barras 2 bar(app.CasosUIAxes,data2.dateRep,data2.cases)

regrading adding a legend using ggplot2 for different lines

半城伤御伤魂 提交于 2021-02-05 09:23:27
问题 I want to add a legend that will tell which color represents which line using ggplot2 . My code is as follows : require(lme4) require(ggplot2) m1 <- lmer(Reaction ~ 1+I(Days) + (1+ Days| Subject) , data = sleepstudy) pred1new1=predict(m1,re.form=NA) To add a legend, i tried scale_colour_manual , but it didnt worked. p21 <- ggplot(data = sleepstudy, aes(x = Days, y = Reaction)) p21+ geom_point() + geom_smooth(col="blue")+ geom_line(aes(y=pred1new1,group = Subject) ,col="red", lwd = 0.5)+ scale

How to add a free text entry as a legend to ggplot?

孤者浪人 提交于 2021-02-05 07:27:07
问题 I'm trying to make a world map with a custom legend on the right side. The legend should be with the prepared text on the left and the generated numbers on the right. I tried but to no avail. I need help My code is as follows: library(dplyr) library(ggplot2) library(ggrepel) library(rworldmap) world_map_without_antarctica <- getMap()[-which(getMap()$ADMIN=='Antarctica'),] #get data from web world_map_without_antarctica_t <- fortify(world_map_without_antarctica) Data <- data.frame( "lon"=c(17