legend

How to adjust the size of matplotlib legend box?

旧时模样 提交于 2019-12-18 10:02:20
问题 I have a graph whose left upper corner is quite blank. So I decide to put my legend box there. However, I find the items in legend are very small and the legend box itself is also quite small . By "small", I mean something like this How can I make the items ( not texts! ) in the legend box bigger? How can i make the box itself bigger? 回答1: To control the padding inside the legend (effectively making the legend box bigger) use the borderpad kwarg. For example, here's the default: import

One combined legend entry for multiple plots

时间秒杀一切 提交于 2019-12-18 09:33:53
问题 For some reason, I would like to plot the line and marker of the same data separately. data1 = (1:1:10)'; data2 = (1:2:10); figure(1); plot(data1,data1,'or'); hold on; plot(data2,data2,'-r'); legend('data'); However it will only display the legend for the first plot. And Matlab seems not to have option to manipulate the legend marker, color and linestyle. How can I make legend like this? Thanks! 回答1: You will need to plot an invisible third plot (with almost no data to keep it fast) to define

How to add legend for vertical lines in ggplot?

久未见 提交于 2019-12-18 08:54:14
问题 I am trying to show a line graph with some vertical lines as indicators of particular time points and have a legend labeling those time points. Based on the example in section 6.4.4 of the book ggplot2, I've tried the following huron<-data.frame(year=1875:1972,level=LakeHuron) vertDf<-data.frame(years=c(1900,1925,1950),labels=c("A","B","C")) pltWithLines<-ggplot(huron, aes (x=year,y=level)) + geom_line() + geom_vline(aes(xintercept=years,color=labels),data=vertDf) + scale_color_manual("Sample

ggplot - Multiple legends arrangement

早过忘川 提交于 2019-12-18 06:00:24
问题 I want to arrange mutiple legend in ggplot with multiple rows and columns. However currently, from the documentation I can only decide there direction or manipulate rows/columns within 1 legend. Am I overlook something? Thanks for any reference point to the solution. Here is the sample code and what I have done and the expect result. data <- seq(1000, 4000, by=1000) colorScales <- c("#c43b3b", "#80c43b", "#3bc4c4", "#7f3bc4") names(colorScales) <- data ggplot() + geom_point(aes(x=data, y=data

ggplot legend showing transparency and fill color

偶尔善良 提交于 2019-12-18 05:42:38
问题 I'm plotting two semi-transparent ribbons together. Using the code below, without the scale_fill_manual portion, I get basically what I want, with a legend called "red" , and labels blue and red . Adding the scale_fill_manual portion allows me to name the legend and its entries what I want, but i lose the transparency of the colored rectangles in the legend. x=1:10 y1=1:10 y2=2:11 y3=10:1 y4=9:0 dt=data.frame(x,y1,y2,y3,y4) library(ggplot2) ggplot(dt)+ geom_ribbon(aes(x=x,ymin=y1,ymax=y2,fill

Legend text color in accordance with line color in jqplot

最后都变了- 提交于 2019-12-18 05:24:09
问题 I am using jqplot to draw multiple lines of different line colors. Also, I have legends whose colors should be in accordance with the corresponding line colors. I seem to find no way to cope with the legend color. So any hint? 回答1: Taken from the question title I understand you want to change the color of legend labels to correspond to the color of series, right? For this reason, since the swatches which are just in front of the labels, we can use them to grab the color which we then set for

Adding to a legend after each iteration

本秂侑毒 提交于 2019-12-18 04:34:51
问题 I run loglog(x,y); legend('First script'); from the first script. Then, hold on; . I run a similar second script. I see two graphs correctly, but only the initial legend. I want to increment the legend from different scripts. How can you add to the legend from a single script? 回答1: Another possible way to do this and it is called 'DisplayName': hold all for ind=1:3 x=[0:0.1:10]; plot(x, sin(x)+ind, 'DisplayName',['sin + ' num2str(ind)]); end legend(gca,'show') Just use this property when

legend and fieldset in android

拟墨画扇 提交于 2019-12-18 03:41:07
问题 I want to know if it's possible in android to do a form like that : At this moment, I made a shape to produce the border (I use this shape as a background of my linearlayout, but i don't know how to deal with the text). Thanks in advance. 回答1: I have managed to get a frame with title using the following technique. Use FrameLayout for the overall layout. Inside add another layout for your main content - this can be anything. For the background of this layout, use a custom XML drawable with

Label minimum and maximum of scale fill gradient legend with text: ggplot2

邮差的信 提交于 2019-12-17 23:42:39
问题 I have a plot created in ggplot2 that uses scale_fill_gradientn . I'd like to add text at the minimum and maximum of the scale legend. For example, at the legend minimum display "Minimum" and at the legend maximum display "Maximum". There are posts using discrete fills and adding labels with numbers instead of text (e.g. here), but I am unsure how to use the labels feature with scale_fill_gradientn to only insert text at the min and max. At the present I am apt to getting errors: Error in

How to create a scatter plot legend with only one symbol for each label?

人走茶凉 提交于 2019-12-17 23:14:51
问题 How can I create a scatter plot legend without two symbols showing up each time? I can understand why you'd want this when you're joining symbols by lines, but for a pure scatter plot, all I want in the legend is one example of the symbol. This plot from a previous stackoverflow post shows the kind of thing I mean: 回答1: In the legend command you can use the scatterpoints option: ax.legend(loc=0, scatterpoints = 1) For a normal plot, it is the option numpoints . Here you can find more