legend

Continuous color bar with separators instead of ticks

*爱你&永不变心* 提交于 2020-07-05 08:10:43
问题 The picture should give a good idea of what I would want to achieve. Ideally, the resulting colour bar would keep a continuous nature, i.e., should be based on a continuous rather than discrete aesthetic, or at least come very close to behave like it. This also means, not just the simple approach of just bringing the legend keys of a discrete fill close enough together. Yes, I could create a fake legend, but I'd like a solution that modifies at the legend drawing level. I would be also very

Continuous color bar with separators instead of ticks

丶灬走出姿态 提交于 2020-07-05 08:09:08
问题 The picture should give a good idea of what I would want to achieve. Ideally, the resulting colour bar would keep a continuous nature, i.e., should be based on a continuous rather than discrete aesthetic, or at least come very close to behave like it. This also means, not just the simple approach of just bringing the legend keys of a discrete fill close enough together. Yes, I could create a fake legend, but I'd like a solution that modifies at the legend drawing level. I would be also very

How to add a legend to the multiple histograms with ggplot?

萝らか妹 提交于 2020-06-28 14:48:52
问题 I am trying to add a legend to the graph but it doesn't work. Do you have any ideas ? Here is my code : ggplot(data =stats_201507_AF ) + geom_histogram(aes(gross_ind),fill="dodgerblue3", show.legend =T,bins=25)+ geom_histogram(aes(net_ind),fill="springgreen4",show.legend = T,bins=25) + geom_histogram(aes(tax_ind),fill="gold2",show.legend = T, bins=25) + xlab("Indices")+ scale_colour_manual(values=c("dodgerblue3","springgreen4","gold2")) I wanted a description for every histogram with a

How can I change legend symbols (key glyphs) to match the plot symbols?

别等时光非礼了梦想. 提交于 2020-06-27 16:47:10
问题 I plot data points in several groups, but then add a box plot of a different variable (same unit). See the image below. How can I change the symbols in the legend to match the symbols in the plot? The code: p <- ggplot(data = tdata, aes( y=Temp ,x=Distance, color=Type)) + geom_point() + geom_boxplot( aes(y = Ambient,x=5,color="Ambient")) p + facet_grid(cols = vars(Time),rows = vars(Day)) The data: structure(list(Day = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,

Stacked bar plot with multiple or different legend for each group

半世苍凉 提交于 2020-06-27 16:25:28
问题 Is it possible to generate a barplot like in the following link using ggplot? https://photos.app.goo.gl/E3MC461dKaTZfHza9 here is what I did library(ggplot2) df <- read.csv(text= "trt,gene,freq,cols M6,ALDH16A1,100.0000000,red M6,Others,0.0000000,lightgrey M12,ALDH16A1,64.6638015,red M12,GBE1,2.0074865,#4C00FF M12,ZNF598,1.5832525,#004CFF M12,CHMP6,1.3503397,#00E5FF M12,C20orf27,1.2033828,#00FF4D M12,NEGR1,0.9676972,#4DFF00 M12,TNFAIP6,0.9122418,#E6FF00 M12,ZSCAN25,0.7375572,#FFFF00 M12,BCL2

Add item to existing Matplotlib legend

一曲冷凌霜 提交于 2020-06-27 13:10:09
问题 Given the following setup: from matplotlib import pyplot as plt fig, ax = plt.subplots() ax.plot([0,1,2,3,4,5,6], label='linear') ax.plot([0,1,4,9,16,25,36], label='square') lgd = ax.legend(loc='lower right') If a function add_patch receives only lgd as an argument, can a custom legend item be added to the legend on top of the existing items, without changing the other properties of the legend? I was able to add an item using: def add_patch(legend): from matplotlib.patches import Patch ax =

How to change background colour of legend in ggplot2?

一个人想着一个人 提交于 2020-06-27 06:52:10
问题 Does anybody know how to change the background colour for the points legend in ggplot2. I have created the plot below and would like to change the white background on the legend? Any ideas? 回答1: You can use the legend.key parameter of theme . From ?theme : legend.key : background underneath legend keys ( element_rect() ; inherits from rect ) That is theme(legend.key = element_rect(fill = "black")) An example: a <- seq(1:5) b <- seq(1:5) c <- seq(1:5) d <- data.frame(a, b, c) ggplot(data = d,

How can I organize my legend into subgroups?

烂漫一生 提交于 2020-06-26 12:27:19
问题 The legend for my bar graph currently lists all the items in the graph in one long list. I would like to have the legend group itself by each column. The number of columns is dynamic so the legend must be able to adjust accordingly. library("phyloseq"); packageVersion("phyloseq") library(ggplot2) library(scales) data("GlobalPatterns") TopNOTUs <- names(sort(taxa_sums(GlobalPatterns), TRUE)[1:50]) gp.ch <- prune_species(TopNOTUs, GlobalPatterns) gp.ch = subset_taxa(gp.ch, Genus != "NA") mdf =

How can I organize my legend into subgroups?

倾然丶 夕夏残阳落幕 提交于 2020-06-26 12:27:15
问题 The legend for my bar graph currently lists all the items in the graph in one long list. I would like to have the legend group itself by each column. The number of columns is dynamic so the legend must be able to adjust accordingly. library("phyloseq"); packageVersion("phyloseq") library(ggplot2) library(scales) data("GlobalPatterns") TopNOTUs <- names(sort(taxa_sums(GlobalPatterns), TRUE)[1:50]) gp.ch <- prune_species(TopNOTUs, GlobalPatterns) gp.ch = subset_taxa(gp.ch, Genus != "NA") mdf =

How can I change the legend linetype in ggplot2?

徘徊边缘 提交于 2020-06-23 12:33:53
问题 I have this simple plot where I cannot change the linetype in the legend according to the linetype in the plot using scale_linetype_manual. The code to produce the plot is : library(ggplot2) x_1 <- rep(0:6, each = 2) pdf_1 <- c(0,0.05,0.05,0.1,0.1,0.15,0.15,0.3,0.3,0.25,0.25,0.15,0.15,0) x_2 <- rep(3:9, each = 2) pdf_2 <- c(0,0.05,0.05,0.1,0.1,0.15,0.15,0.3,0.3,0.25,0.25,0.15,0.15,0) data_1 <- data.frame(x_1, pdf_1,x_2,pdf_2) ggplot()+ geom_line(data=data_1,aes(x=x_1, y=pdf_1, color=