legend-properties

Is it possible to add a string as a legend item in matplotlib

这一生的挚爱 提交于 2019-12-17 07:26:27
问题 I am producing some plots in matplotlib and would like to add explanatory text for some of the data. I want to have a string inside my legend as a separate legend item above the '0-10' item. Does anyone know if there is a possible way to do this? This is the code for my legend: ax.legend(['0-10','10-100','100-500','500+'],loc='best') 回答1: Sure. ax.legend() has a two argument form that accepts a list of objects (handles) and a list of strings (labels). Use a dummy object (aka a "proxy artist")

Is it possible to add a string as a legend item in matplotlib

半城伤御伤魂 提交于 2019-12-17 07:26:02
问题 I am producing some plots in matplotlib and would like to add explanatory text for some of the data. I want to have a string inside my legend as a separate legend item above the '0-10' item. Does anyone know if there is a possible way to do this? This is the code for my legend: ax.legend(['0-10','10-100','100-500','500+'],loc='best') 回答1: Sure. ax.legend() has a two argument form that accepts a list of objects (handles) and a list of strings (labels). Use a dummy object (aka a "proxy artist")

ggplot2: modify legend's elements for two factors in scatterplot {ggplot2}?

寵の児 提交于 2019-12-13 19:24:11
问题 I wish my scatter plot displays two factors: by point size and by shades of grey : a1<-c(seq(1,10,1)) a2<-c(seq(11,20,1)) a3<-c(rep(c(1,2),each = 5)) a4<-c(rep(c(5,10,15,20,25),2)) df<-data.frame(a1,a2,a3,a4) t1<-theme( plot.background = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_blank(), panel.background = element_blank(), axis.line = element_line(size=.4)) ggplot(df, aes(x= a1, y= a2)) + geom_point(aes(alpha=factor(a3),

Matlab: change order of entries in Figure legend

我只是一个虾纸丫 提交于 2019-12-13 02:26:58
问题 I have a Figure file where I would like to change the order of the entries (e.g., put the first entry as third one). I saved this Figure.fig long time ago so I am not sure if I can recover the original code. Here I show you my plot: I want the legend elements to be in a decreasing order ( as in the picture) but due to a mistake my second entry is referring to the wrong plot (it says "25 years" but the plot is actually referred to the lowest trend, corresponding to the "9 years" trend). Can I

Legend as text alongside points for each category and with same collor

纵饮孤独 提交于 2019-12-12 13:56:59
问题 I would like to make scatter plot in R, of variables Y and X over categories Z (separated by colors) but with a special legend. Not a legend box, but for the category names to appear as texts along the points for that category, and the text be the same color as the points. Is there a way for R to do this automatically? PS: I know I this could be done "manually" adding "text()" and specifying the location and color of each category For example, I'm trying to replicate the look of this chart

Plot with multiple axes but only one legend

本秂侑毒 提交于 2019-12-11 18:27:03
问题 The following code produces a plot with two lines reffering to the left y-axis and one line referring to the right y-axis. Both plots have their own legend, but I want only one legend listing all 3 lines. I tried to just put the 'y1' , 'y2' strings into the 2nd legend -command as well, but that didn't work out. line(x,y1,'b','LineWidth',2) line(x,y2,'Color',[0,0.6,0.5],'LineWidth',2) legend('y1','y2'); ax1 = gca; ax2 = axes('Position',ax1.Position,'YAxisLocation','right', 'Color','none',

How to add a string as the artist in matplotlib legend?

你。 提交于 2019-12-11 14:02:21
问题 I am trying to create a legend in a python figure where the artist is a string (a single letter) which is then labelled. For example I would like a legend for the following figure: import numpy as np import matplotlib.pyplot as plt import string N = 7 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) area = np.pi * (15 * np.random.rand(N))**2 plt.scatter(x, y, s=area, c=colors, alpha=0.5) for i,j in enumerate(zip(x,y)): plt.annotate(list(string.ascii_uppercase)[i],xy=j)

leaflet - Adding a legend title

為{幸葍}努か 提交于 2019-12-10 13:13:59
问题 I am new to Leaflet and I am currently struggling with tutorials. So far I managed to create an interactive clorophet map, like in the example http://leafletjs.com/examples/choropleth.html. I have a question: is it possible to add a title (simple text, not dynamic) to the legged located on the bottomright of the page? Could anyone tell me how, by just referring to the linked example? Many thanks, G. 回答1: You just need to add your title under "THE TITLE"... var legend = L.control({position:

Printing too big legend box in RStudio

痞子三分冷 提交于 2019-12-10 10:04:35
问题 I am trying to add a legend to my plot and I don't understand why I can't control for its size and/or location. I know there is a lot of posts about it but I already tried to reproduce the solutions and for whatever reason it does not seem to work in my RStudio. Here is what I tried: How to scale legend box or enlarge font size in the legend box in R And here is how my plot looks like when I run the exact same code (you can see the legend is in the middle of the plot): my plot-1 I also tried

How to add a legend for two geom layers in one ggplot2 plot?

江枫思渺然 提交于 2019-12-09 06:40:07
问题 I've got a data frame that looks like this: glimpse(spottingIntensityByMonth) # Observations: 27 # Variables: 3 # $ yearMonth <dttm> 2015-05-01, 2015-06-01, 2015-07-01, 2015-08-01, 2015-09-01, 2015-10-01, 2... # $ nClassificationsPerDayPerSpotter <dbl> 3.322581, 13.212500, 13.621701, 6.194700, 18.127778, 12.539589, 8.659722, ... # $ nSpotters <int> 8, 8, 22, 28, 24, 22, 24, 27, 25, 29, 32, 32, 21, 14, 18, 13, 20, 19, 15, ... I am trying to plot it with ggplot2 like so: ggplot() + geom_col