legend

Make squared in legend instead of lines Matlab

跟風遠走 提交于 2019-12-29 08:49:06
问题 I have the following code, which plots a 'map' using imagesc, and provides a legend, see output attached. I am trying to replace the lines in the legend with solid squares. My attamps to far leave the lines and ad hollow squares (including a random square in the top left corner of the figure) figure(6) imagesc(lut) title('Ditribution of Land use Types') ylabel('Longitude') xlabel('Latitude') caxis([0, 7]) myColorMap = jet(6); imagesc(lut, 'AlphaData', ~isnan(lut)) colormap(myColorMap); L =

Centering matplotlib legend entries within incomplete/unfilled rows?

我们两清 提交于 2019-12-29 08:16:25
问题 Say I'm making a plot with five items, and only have room to create a legend with 3 columns (more columns than this would be too wide), e.g. import matplotlib.pyplot as plt f, a = plt.subplots() for i in range(5): a.plot(np.arange(10),np.random.rand(10),label='Item #%d'%i) a.legend(ncol=3) The trailing two entries in the bottom row are left-aligned , leaving a big empty space on the right that isn't very aesthetically pleasing. This becomes especially problematic when you have to label very

Centering matplotlib legend entries within incomplete/unfilled rows?

北慕城南 提交于 2019-12-29 08:16:19
问题 Say I'm making a plot with five items, and only have room to create a legend with 3 columns (more columns than this would be too wide), e.g. import matplotlib.pyplot as plt f, a = plt.subplots() for i in range(5): a.plot(np.arange(10),np.random.rand(10),label='Item #%d'%i) a.legend(ncol=3) The trailing two entries in the bottom row are left-aligned , leaving a big empty space on the right that isn't very aesthetically pleasing. This becomes especially problematic when you have to label very

Legend ordering in ggplot2

跟風遠走 提交于 2019-12-29 07:17:20
问题 I created the following graph in R using ggplot2 . As you can see, the order in the legend is not exactly what it should be: I would like to have "4 years" coming after "1 year". I was wondering how this can be achieved. Source code: require("ggplot2") require("scales") # I have 5 data files containing two columns (x and y values) d1 = read.table("1yr.txt")$V2 d2 = read.table("4yr.txt")$V2 d3 = read.table("15yr.txt")$V2 d4 = read.table("25yr.txt")$V2 d5 = read.table("40yr.txt")$V2 rank1 =

ggplot2: Change factor order in legend

女生的网名这么多〃 提交于 2019-12-29 01:43:13
问题 I have a a line graph and I want to reorder the way in which the factors appear in the legend. I have tried scale_fill_discrete but it doesn't change the order. Here's a simulation of my problem: df <- data.frame(var1=c("F", "F", "F", "B", "B", "B"), var2=c("levelB", "levelC", "levelA"), value=c("2.487585", "2.535944", "3.444764", "2.917308", "2.954155","3.739049")) p <- ggplot(data=df, aes(x=var1, y=value, group=var2, colour=var2, shape = var2)) + geom_line(size = 0.8) + geom_point()+ xlab(

How to disable legend in nvd3 or limit it's size

本小妞迷上赌 提交于 2019-12-28 14:22:10
问题 I'm using nvd3 and have a few charts where the legend is much to large. E.g. a scatter/bubble with 15 groups and the group names are long. The legend is so large that it leaves almost no room for the chart itself. Is there a way to remove the legend or toggle the legend or limit the height/width it is taking up? Any example would be great. Also, is there a way to have the bubble show a descriptive string? Right now when you stand on top of a bubble it highlights the x/y coordinates. I also

ggplot2 custom legend shapes

别说谁变了你拦得住时间么 提交于 2019-12-28 06:35:51
问题 When we have both shape and color legend in scatter plot, the shape of color legend is misleading: foo <- data.frame( length=runif(10), height=runif(10), group=as.factor(sample(3,10,rep=T)), quality=as.factor(sample(2,10,rep=T)) ) ggplot(foo, aes(x = length, y = height, color=group, shape=quality)) + geom_point(size=5) This will produce the plot below. As you see, the "circle" shape is reserved for the objects of quality==1 , however in the group legend, all 3 groups are presented in "circle"

Remove line through marker in matplotlib legend

心已入冬 提交于 2019-12-28 04:00:34
问题 I have a matplotlib plot generated with the following code: import matplotlib.pyplot as pyplot Fig, ax = pyplot.subplots() for i, (mark, color) in enumerate(zip( ['s', 'o', 'D', 'v'], ['r', 'g', 'b', 'purple'])): ax.plot(i+1, i+1, color=color, marker=mark, markerfacecolor='None', markeredgecolor=color, label=i) ax.set_xlim(0,5) ax.set_ylim(0,5) ax.legend() with this as the generated figure: I don't like the lines through the markers in the legend. How can I get rid of them? 回答1: You can

Make a rectangular legend, with rows and columns labeled, in grid

a 夏天 提交于 2019-12-28 02:52:08
问题 I've got a ggplot where I'm mapping factors to both fill and alpha, like this: set.seed(47) the_data <- data.frame(value = rpois(6, lambda=20), cat1 = rep(c("A", "B"), each = 3), cat2 = rep(c("X", "Y", "Z"), 2)) ggplot(the_data, aes(y = value, x = cat2, alpha = cat1, fill = cat2)) + geom_bar(stat = "identity", position = "dodge") + scale_alpha_discrete(range = c(0.5, 1)) + theme_bw() The people I'm producing it for don't find the legend for alpha very clear. I think a good alternative would

How can I add labels onto the pie pieces that are large enough to contain them, and alongside those that aren't?

ε祈祈猫儿з 提交于 2019-12-25 19:01:57
问题 I've got simple bogus data that generates this Excel Chart: This is the code: object misValue = System.Reflection.Missing.Value; //add data _xlSheet.Cells[11, 11] = ""; _xlSheet.Cells[11, 12] = "Student1"; _xlSheet.Cells[11, 13] = "Student2"; _xlSheet.Cells[11, 14] = "Student3"; _xlSheet.Cells[12, 11] = "Term1"; _xlSheet.Cells[12, 12] = "80"; _xlSheet.Cells[12, 13] = "65"; _xlSheet.Cells[12, 14] = "45"; _xlSheet.Cells[13, 11] = "Term2"; _xlSheet.Cells[13, 12] = "78"; _xlSheet.Cells[13, 13] =