legend

Cannot add `margin` to `<legend>` element in Safari & Chrome (WebKit)

左心房为你撑大大i 提交于 2019-12-17 23:10:09
问题 EDIT : As of 2012-06-11 this bug has been finally fixed! https://bugs.webkit.org/show_bug.cgi?id=35981#c1 I have some pretty straightforward markup: <form action=""> <fieldset class="compact"> <legend>Member Tools</legend> <label for="username">Username</label> <input name="username" id="username" type="text"/> <label for="password">Password</label> <input name="password" id="password" type="password" /> </fieldset> </form> I am attempting to add a small margin to the bottom of the legend

Manually set color of points in legend

落花浮王杯 提交于 2019-12-17 22:46:27
问题 I'm making a scatter plot which looks like this: (MWE at bottom of question) As can be seen in the image above the colors of the points in the legend are set to blue automatically by matplotlib . I need to set this points to some other color not present in the colormap (ie: black) so they won't generate confusion with the colors associated with said colormap. I looked around but the matplotlib.legend module does not seem to accept a color keyword. Is there any way to do this? Here's the MWE:

ggplot2: how to remove slash from geom_density legend

烂漫一生 提交于 2019-12-17 22:45:27
问题 I'm trying to plot some overlapping density plots in ggplot2. I'm running into a problem where I cannot remove the diagonal slash from the legend. I have tried using scale_fill_manual() and legend.key as well as the hack from R Cookbook, but I cant seem to get it right. data(iris) iris=iris cols=brewer.pal(3,"Set1") ggplot(iris) + geom_density(position="identity",aes(x=iris$Sepal.Length,fill=cols[1]), colour="black",alpha=.5) + geom_density(position="identity",aes(x=iris$Sepal.Width,fill=cols

Make Chart Legend represent two colors

大兔子大兔子 提交于 2019-12-17 20:29:27
问题 I created a column chart in my application which look like this: As you can see the positive values are green and the negative values are red. I need to represent this in the legend. I just don't know how. What I already tried: I added CustomItems to the Legend . Here is the code: Legend currentLegend = chart.Legends.FindByName(chart.Series[series].Legend); if (currentLegend != null) { currentLegend.LegendStyle = LegendStyle.Table; LegendItem li = new LegendItem(); li.Name = series; li.Color

Replace Matplotlib legend's labels with image

和自甴很熟 提交于 2019-12-17 20:25:30
问题 I would like to use image instead of labels in the legend. For example, I draw 2 lines and show a legend : import matplotlib.pyplot as plt plt.plot([1,2],label="first_image") plt.plot([2,1],label="second_image") plt.legend() plot.show() But I would like to have something like this : Note that this is not a duplicate of Insert image in matplotlib legend , My issue is "change the label into an image", while the other is "change the legend's symbol into an image" 回答1: The concept for creating an

Setting a fixed size for points in legend

亡梦爱人 提交于 2019-12-17 18:12:25
问题 I'm making some scatter plots and I want to set the size of the points in the legend to a fixed, equal value. Right now I have this: import matplotlib.pyplot as plt import numpy as np def rand_data(): return np.random.uniform(low=0., high=1., size=(100,)) # Generate data. x1, y1 = [rand_data() for i in range(2)] x2, y2 = [rand_data() for i in range(2)] plt.figure() plt.scatter(x1, y1, marker='o', label='first', s=20., c='b') plt.scatter(x2, y2, marker='o', label='second', s=35., c='r') # Plot

Can ggplot2 control point size and line size (lineweight) separately in one legend?

☆樱花仙子☆ 提交于 2019-12-17 16:28:23
问题 An example using ggplot2 to graph groups of data points and lines connecting the means for each group, mapped with the same aes for shape and for linetype : p <- ggplot(mtcars, aes(gear, mpg, shape = factor(cyl), linetype = factor(cyl))) + geom_point(size = 2) + stat_summary(fun.y = mean, geom = "line", size = 1) + scale_shape_manual(values = c(1, 4, 19)) Problem is that point symbols in the legend appear a bit too small to see, relative to the line symbols: Trying to enlarge point size in

Two geom_points add a legend

拈花ヽ惹草 提交于 2019-12-17 15:58:20
问题 I plot a 2 geom_point graph with the following code: source("http://www.openintro.org/stat/data/arbuthnot.R") library(ggplot2) ggplot() + geom_point(aes(x = year,y = boys),data=arbuthnot,colour = '#3399ff') + geom_point(aes(x = year,y = girls),data=arbuthnot,shape = 17,colour = '#ff00ff') + xlab(label = 'Year') + ylab(label = 'Rate') I simply want to know how to add a legend on the right side. With the same shape and color. Triangle pink should have the legend "woman" and blue circle the

Dynamic Legend (Updates in every recursion)

倖福魔咒の 提交于 2019-12-17 15:41:58
问题 I got a for i=1:15 . Inside I generate a variable d=1:0.01:10 , which is the x'x axis and based on this, I create a continuous function F(d) which has 2 unique variables pitch and yaw. I then plot this using different colors in every recursion using cmap = hsv(15); . So then it is: d=1:0.01:10; cmap = hsv(15); for i=1:15 pitch = unidrnd(10); yaw = unidrnd(10); for j=1:length(d) F(j) = d(j)*3*pitch*yaw; %// some long calculation here end p1 = plot(d,F,'Linewidth', 1.0); title ('blah blah') set

Stop matplotlib repeating labels in legend

落花浮王杯 提交于 2019-12-17 08:29:08
问题 Here is a very simplified example: xvalues = [2,3,4,6] for x in xvalues: plt.axvline(x,color='b',label='xvalues') plt.legend() The legend will now show 'xvalues' as a blue line 4 times in the legend. Is there a more elegant way of fixing this than the following? for i,x in enumerate(xvalues): if not i: plt.axvline(x,color='b',label='xvalues') else: plt.axvline(x,color='b') 回答1: plt.legend takes as parameters A list of axis handles which are Artist objects A list of labels which are strings