legend

Irrelevant legend information in ggplot2

南笙酒味 提交于 2019-11-30 20:11:22
When running this code (go ahead, try it): library(ggplot2) (myDat <- data.frame(cbind(VarX=10:1, VarY=runif(10)), Descrip=sample(LETTERS[1:3], 10, replace=TRUE))) ggplot(myDat,aes(VarX,VarY,shape=Descrip,size=3)) + geom_point() ... the "size=3" statement does correctly set the point size. However it causes the legend to give birth to a little legend beneath it, entitled "3" and containing nothing but a big dot and the number 3. This does the same ggplot(myDat,aes(VarX,VarY,shape=Descrip)) + geom_point(aes(size=3)) Yes, it is funny. It would have driven me insane a couple hours ago if it weren

removing a layer legend in ggplot

淺唱寂寞╮ 提交于 2019-11-30 19:35:44
Another ggplot legend question! I have a dataset of the form test <- data.frame( cond = factor(rep(c("A", "B"), each=200)), value = c(rnorm(200), rnorm(200, mean=0.8)) ) So two groups and some values and I want to plot the density. I also want to add a line indicating the mean for each group to the plot so I: test.cdf <- ddply(test, .(cond), summarise, value.mean=mean(value)) Then in ggplot call: ggplot(test, aes(value, fill=cond)) + geom_density(alpha=0.5) + labs(x='Energy', y='Density', fill='Group') + opts( panel.background=theme_blank(), panel.grid.major=theme_blank(), panel.grid.minor

Move and resize legends-box in matplotlib

流过昼夜 提交于 2019-11-30 18:35:56
I'm creating plots using Matplotlib that I save as SVG, export to .pdf + .pdf_tex using Inkscape, and include the .pdf_tex-file in a LaTeX document. This means that I can input LaTeX-commands in titles, legends etc., giving an image like this which renders like this when I use it in my LaTeX document. Notice that the font for the numbers on the axes change, and the LaTeX-code in the legend is compiled: Code for the plot (how to export to SVG not shown here, but can be shown on request): import numpy as np x = np.linspace(0,1,100) y = x**2 import matplotlib.pyplot as plt plt.plot(x, y, label =

Highchart pie legend circles

て烟熏妆下的殇ゞ 提交于 2019-11-30 18:27:58
问题 Im using a highchart pie chart to create a donut chart but would like the legend icons to be circles any ideas??? Below is the mockup and the actual web version. Thanks... 回答1: I prepared solution based on pie chart. Legend is generated on data points, automatically as HTML list. Then all elements gets colors from series, and use CSS3 to generate circle object (border-radius). As a result you need to add click event. http://jsfiddle.net/N3KAC/1/ $legend = $('#customLegend'); $.each(chart

ggplot2: Making changes to symbols in the legend

余生长醉 提交于 2019-11-30 18:27:50
问题 I'm having a problem making the symbols in the legend of my plot match those in the plot itself. Suppose the data has four columns like this data = data.frame(x = sample(1:10, 10, replace=TRUE), y = sample(1:10, 10, replace=TRUE), Rank = sample(1:10, 10, replace = TRUE), Quantified = factor(sample(1:2, 10, replace = TRUE)) ) I would like points to be different sizes (distinguished by 'Rank') and represented by different symbols (crosses and open circles, distinguished by 'Quantified'). My

multiple bquote items in legend of an R plot

柔情痞子 提交于 2019-11-30 18:17:31
Following works, (copy & paste into R) a=123 plot(1,1) legend('bottomleft',legend=bquote(theta == .(a))) I want to have multiple items in the legend. All with greek letters. As a simple example, if I repeat the item twice the code does not work anymore a=123 plot(1,1) legend('bottomleft',legend=c(bquote(theta == .(a)),bquote(theta == .(a)))) I have tried many more complicated expressions but they all did not work. Any help will be appreciated. In this case, plotmath is not able to coerce the list of calls to expressions. > cs <- c(bquote(theta == .(a)),bquote(theta == .(a))) > cs [[1]] theta =

Overlay base R graphics on top of ggplot2

ε祈祈猫儿з 提交于 2019-11-30 18:14:49
问题 I have a plot in ggplot and I wish to overlay a map legend that I have created with base R code. I do not know how to overlay base R graphics on top of a ggplot and would be grateful for assistance. Currently I have a ggplot legend that looks like this: There are several things that I do not like about this legend that I would like to change (and that resulted in me thinking it would be easier to resort to base R graphics to do so). In particular, I wish to eliminate the white space between

Having subsections in a legend of a plot in R?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 17:56:35
问题 I generate the following legend: legend( "bottomleft" , legend=c( expression(bold("Long:" ~ (w==10^2 ~ ";" ~ h==10^5))) , expression(q[c] == 0.00 ~ ";" ~ beta == 0) , expression(q[c] == 0.05 ~ ";" ~ beta == 2) , expression(q[c] == 0.10 ~ ";" ~ beta == 10) , expression(q[c] == 0.20 ~ ";" ~ beta == 10) , expression(q[c] == 0.40 ~ ";" ~ beta == 10) , expression(bold("Wide:" ~ (w==10^3 ~ ";" ~ h==10^3))) , expression(q[c] == 0.00 ~ ";" ~ beta == 0) , expression(q[c] == 0.05 ~ ";" ~ beta == 2) ,

R Leaflet - use date or character legend labels with colorNumeric() palette

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 17:03:22
问题 I have a dataset with lat/lon and a timestamp. I want the color of the markers to show time with a continous palette. I am using colorNumeric() with julian dates earlier created using julian(x, "2015-01-01") . data = structure(list(timestamp = structure(c(1434056453, 1434148216, 1434153635, 1434245436, 1434358840, 1434364288, 1434369611, 1434461435, 1434466830, 1434558725), class = c("POSIXct", "POSIXt"), tzone = ""), lon = c(-119.8777, -119.9614, -119.8769, -119.8775, -120.2283, -120.2285,

Irrelevant legend information in ggplot2

我们两清 提交于 2019-11-30 16:57:38
问题 When running this code (go ahead, try it): library(ggplot2) (myDat <- data.frame(cbind(VarX=10:1, VarY=runif(10)), Descrip=sample(LETTERS[1:3], 10, replace=TRUE))) ggplot(myDat,aes(VarX,VarY,shape=Descrip,size=3)) + geom_point() ... the "size=3" statement does correctly set the point size. However it causes the legend to give birth to a little legend beneath it, entitled "3" and containing nothing but a big dot and the number 3. This does the same ggplot(myDat,aes(VarX,VarY,shape=Descrip)) +