legend

How to only make one legend name italic in base R plot?

。_饼干妹妹 提交于 2019-12-19 10:17:40
问题 I want to add a legend to a plot in which only one of the legend names is italicized . I'm using plot() in base R. However, I need that italicized line to contain variable numbers, so I use bquote . What I've tried does not work: a <- 2 ; b <- 5 plot(a,b) l1 <- bquote(Italic ~ .(a) + .(b)) l2 <- bquote(a + b) legend(x='topright',legend = bquote(italic(.(l1)))) legend(x='topleft',legend = c(bquote(italic(.(l1))),l2)) Notice that when I leave the expression on its own (RIGHT LEGEND), it

ggplot2: Top legend key symbol size changes with legend key label

江枫思渺然 提交于 2019-12-19 08:12:50
问题 The Problem I want to place the legend of my plot above the plot. I also want to place the legend key symbol (colored squares) above the legend key labels (legend text). Unfortunately, when I do this, the legend key symbol "stretches" to fit the size of the label. I imagine ggplot2 is working fine, but how could I manually override this feature? How do I keep a consistent legend key symbol across the top with labels of variable lengths? Reproducible Example ( It's not necessarily a minimal

What do different icons and symbols in Android Studio's Structure sidebar mean?

别来无恙 提交于 2019-12-19 07:15:20
问题 When I click on 'Structure' sidebar in Android Studio, it displays the contents of the current class. However there are certain icons & symbols used to indicate different members, e.g., a circle with letter m for methods, etc. Where do I get the complete list and the details for all the icons & symbols? (something like a legend/key that explains the various icons & symbols is what I'm looking for) Thanks! 回答1: Follow the link below and you will get your answer about different icons and

Align two line legend title to the left with expression()

孤街浪徒 提交于 2019-12-19 06:40:52
问题 Using this script df <- data.frame(x = 1:5, y = 1:5, color = letters[1:5]) ggplot(df, aes(x, y, fill = color)) + geom_point(size = 4, pch = 21) + guides(fill = guide_legend( title = expression(atop(Median~Nitrate-Nitrogen~(NO[3]^{textstyle("-")}-N), ".\n Concentration"~(mg~L^{textstyle("-")}))))) I got this figure Any suggestions how to align the second line of the legend title to the left? 回答1: quick and ugly answer but it does the job until someone post better... ggplot(df, aes(x, y, fill =

Multiple legends for the same aesthetic

荒凉一梦 提交于 2019-12-19 06:03:01
问题 I'm trying to use facet_grid or facet_wrap in conjunction with geom_raster . However, in each panel, the z aesthetic is on a different scale. For example, ##Data at end of question ggplot(dd, aes(x,y)) + geom_raster(aes(fill=z)) + facet_grid(type ~ var) gives . However, since the average values of C and D are around 0 and 100 respectively, we lose a lot of resolution. You could also try: ##Change C to D to get other panel ggplot(subset(dd, var=="C"), aes(x,y))+ geom_raster(aes(fill=z)) +

ggplot legends when plot is built from two data frames

荒凉一梦 提交于 2019-12-19 06:01:31
问题 I have data coming from two different data frames. I am trying to create legend for each data frame. I know I can combine the data frame and do it, but because of my data source it makes the most sense to plot from two different data frames. Please find the simplified example below. I have gotten close but the 'Main Forecast' in the legend is only white color. I want to show where 'Main Forecast' is red on the outside and white on the inside. x = seq(1,10, 1) y = seq(10,100, 10) df = data

How to hide/toggle legends based on addLayerControl() in Leaflet for R

醉酒当歌 提交于 2019-12-18 16:59:29
问题 I'm wondering how to hide/toggle legends based on addLayerControl() in Leaflet for R? When option layer a is toggled, then the data of option layer b is not showed by addPolygons() because I can use GROUP. However, the addLegend() option doesn't have the GROUP functionality so I'm not able to hide the legend of group layer b(blue) when I selected group layer a(red): source: https://gis.stackexchange.com/questions/214773/how-to-hide-toggle-legends-with-layer-controls-in-leaflet-for-r Do you

Change main plot legend label text

柔情痞子 提交于 2019-12-18 11:18:17
问题 So far I have been able to label the subplots just fine but I'm having an issue with the main one. Here's the relevant part of my code: data_BS_P = data[channels[0]] data_BS_R = data[channels[1]] data_BS_Y = data[channels[2]] plot_BS_P = data_BS_P.plot() #data_BS_P is a pandas dataframe axBS = plot_BS_P.gca() axBS.plot(data_BS_R, label='Roll') axBS.plot(data_BS_Y, label='Yaw') axBS.set_ylabel('Amplitude (urad)') axBS.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05), ncol=3, fancybox=True

Reduce size of legend area in barplot

假装没事ソ 提交于 2019-12-18 11:06:21
问题 I can't reduce the size of the legend in this plot. Could someone help me out? I want it to appear topright, but with no more than 20% of the height of plot area a <- c(3, 2, 2, 2, 1, 2 ) barplot(a, beside = T, col = 1:6, space = c(0, 2)) legend("topright", legend = c("a", "b", "c", "d", "e", "f"), fill = 1:6, ncol = 2) 回答1: The cex parameter will do that for you. a <- c(3, 2, 2, 2, 1, 2 ) barplot(a, beside = T, col = 1:6, space = c(0, 2)) legend("topright", legend = c("a", "b", "c", "d", "e"

Matplotlib: Color-coded text in legend instead of a line

我是研究僧i 提交于 2019-12-18 10:55:10
问题 On certain LCD monitors, the color of the horizontal lines in the legend is hard to tell apart. (See the image attached). So instead of drawing a line in the legend, is it possible to just color code the text itself? so another words, have "y=0x" in blue, "y=1x" in green, etc... import matplotlib.pyplot as plt import numpy as np x = np.arange(10) fig = plt.figure() ax = plt.subplot(111) for i in xrange(5): ax.plot(x, i * x, label='$y = %ix$' % i) ax.legend() plt.show() PS. if the line could