legend

Add legend to pie chart in dc.js

妖精的绣舞 提交于 2019-12-01 05:33:56
I'm building a dc.js-based visualization where one of the charts is a pie chart. See: http://jsfiddle.net/luiseth/t8we6/ The peculiarity of my case is that the labels that this chart will display are usually rather long, so much that usually get clipped by the chart's container (the <div> ). So I thought of having them appear on a legend, but I haven't been able to figure how to have the legend appear to the right of the chart. How can I do that? Playing around with the width has not helped at all, since the chart gets positioned at the center of the <div> . My code at the moment is: chart

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

限于喜欢 提交于 2019-12-01 04:46:18
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? quick and ugly answer but it does the job until someone post better... ggplot(df, aes(x, y, fill = color)) + geom_point(size = 4, pch = 21) + guides(fill = guide_legend( title = expression(atop(Median

How to increase marker size of the legend in scatter plot in MATLAB 2014b? [duplicate]

你。 提交于 2019-12-01 04:00:04
问题 This question already has an answer here : Change legend line style (1 answer) Closed 4 years ago . I found marker size in the scatter plot and the legend is different in MATLAB 2014b. I searched & found some solution from earlier version of MATLAB, which are not applicable in the latest version. In my current version, the marker size in legend is so small that it is hardly distinguishable. Any help? figure; hold on s1 = scatter(1, 1, 150, 'k', 'o') s2 = scatter(1, 2, 150, 'k', '+') s3 =

ggplot legends when plot is built from two data frames

只谈情不闲聊 提交于 2019-12-01 03:46:06
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.frame(x=x, y=y) df2 = data.frame(x=5, y=50) p = ggplot(data=df) + geom_point(data=df,aes(x=x, y=y, color=

ggplot2: how to separate geom_polygon and geom_line in legend keys?

假装没事ソ 提交于 2019-12-01 03:26:33
问题 I want to: remove the line inside geom_polygon legend key and remove the border around the geom_line legend key. The desired output would be My failed attempt so far. Thank you in advance for any help! library(ggplot2) set.seed(1337) dat <- structure(list(id = structure(c(2L, 2L, 2L, 2L), .Label = c("1.1", "1.2", "1.3", "2.1", "2.2", "2.3"), class = "factor"), value = c(3.1, 3.1, 3.1, 3.1), x = c(2.2, 1.1, 1.2, 2.5), y = c(0.5, 1, 2.1, 1.7)), class = "data.frame", row.names = c(NA, -4L)) line

Highchart pie legend circles

牧云@^-^@ 提交于 2019-12-01 00:15:34
Im using a highchart pie chart to create a donut chart but would like the legend icons to be circles any ideas??? Below is the mockup and the actual web version. Thanks... I prepared solution based on pie chart. Legend is generated on data points, automatically as HTML list. Then all elements gets colors from series, and use CSS3 to generate circle object (border-radius). As a result you need to add click event. http://jsfiddle.net/N3KAC/1/ $legend = $('#customLegend'); $.each(chart.series[0].data, function (j, data) { $legend.append('<div class="item"><div class="symbol" style="background

ggplot2: Making changes to symbols in the legend

流过昼夜 提交于 2019-11-30 23:23:13
I'm having a problem making the symbols in the legend of my plot match those in the plot itself. Suppose the data has four columns like this data = data.frame(x = sample(1:10, 10, replace=TRUE), y = sample(1:10, 10, replace=TRUE), Rank = sample(1:10, 10, replace = TRUE), Quantified = factor(sample(1:2, 10, replace = TRUE)) ) I would like points to be different sizes (distinguished by 'Rank') and represented by different symbols (crosses and open circles, distinguished by 'Quantified'). My code is ggplot(data, aes(x = x, y = y)) + geom_point(aes(size = Rank, shape = Quantified)) + scale_shape

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

主宰稳场 提交于 2019-11-30 22:41:53
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 have any idea how to do this? Regards, Joris In case anyone is looking at this in the future, there's a

R Leaflet - use date or character legend labels with colorNumeric() palette

[亡魂溺海] 提交于 2019-11-30 21:26:26
I have a dataset with lat/lon and a timestamp. I want the color of the markers to show time with a continous palette. I am using colorNumeric() with julian dates earlier created using julian(x, "2015-01-01") . data = structure(list(timestamp = structure(c(1434056453, 1434148216, 1434153635, 1434245436, 1434358840, 1434364288, 1434369611, 1434461435, 1434466830, 1434558725), class = c("POSIXct", "POSIXt"), tzone = ""), lon = c(-119.8777, -119.9614, -119.8769, -119.8775, -120.2283, -120.2285, -119.8429, -120.0954, -120.3957, -120.4421), lat = c(34.4041,34.376, 34.4061, 34.4021, 34.4696, 34.4697,

ggplot2: boxplot with colors and text labels mapped to combination of two categorical variables

强颜欢笑 提交于 2019-11-30 20:48:06
I would like to create a boxplot with ggplot2 from a dataset densityAGRLKA with 3 categorical variables (species, location, position) on the x-axis. The following function: ggplot(densityAGRLKA, aes(species, density, fill=location, alpha=position), dodge=species, position) + stat_boxplot(geom ='errorbar') + geom_boxplot() creates a plot, in which the grouping of the species is fine, but the colours are misleading. I have no idea how to fix this. I need a plot with the following properties: the data is grouped by species within the group by location , and within the location in the order top