legend-properties

ggplot2: Formatting Legend Categories

若如初见. 提交于 2020-01-11 03:57:49
问题 I would like to be able to do something like this: https://stackoverflow.com/a/30036603, except with "legend.text" instead of "axis.text.x". Is this possible? It would be something like this, except it's not currently working (all labs are italicized): data <- data.frame(labs = c("Oranges", "Apples", "Cucumbers"), counts = c(5, 10, 12)) ggplot(data = data) + geom_bar(aes(x = labs, y = counts,fill=labs), stat="identity") + theme(axis.text.x=element_text(face=ifelse(levels(data$labs)==

R Leaflet Legend: specify order instead of alphabetical

僤鯓⒐⒋嵵緔 提交于 2020-01-04 15:15:36
问题 I added legend to r leaflet code and output is this I would like the order to be GREEN "More than 66%" ORANGE "Between 33% and 66%" RED "Less than 33%" Code sep <- read.csv("31R_SEP_assets_csv - Copy.csv") Sub1 <- sep[grep("SEP.12", names(sep))] sep$newCol <- 100*rowSums(Sub1)/rowSums(sep[4:7]) # create a new grouping variable Percent_SEP12_Assets <- ifelse(sep[,8] <= 33, "Less than 33%", ifelse(sep[,8] >= 66, "More than 66%", "Between 33% and 66%")) Color_Assets <- colorFactor(c("darkgreen",

How to add a custom legend for geom_hline

最后都变了- 提交于 2020-01-02 08:50:07
问题 Using the data below, notice the legend does not properly describe geom_hline: df<-data.frame( points=c(.153,.144,.126,.035, .037, .039, .010,.015,.07), days=gl(3,1,9,labels=c("Sun","Mon","Tues")), lang=c("en","en","en","pt","pt","pt","ko","ko","ko")) ggplot(data=df[df$lang=="en",])+ geom_point(aes(x=days,y=points),size=5,colour='cyan',show_guide=F)+ geom_point(aes(x=days,y=points,colour=days),size=4,show_guide=F)+ facet_wrap(~lang,ncol=1,scales="free")+ xlab("")+ ylab("")+ scale_y_continuous

ggplot legend key color and items

末鹿安然 提交于 2019-12-24 01:45:24
问题 Using the following data frame: sdf<-data.frame(hours=gl(n=3,k=1,length=9,labels=c(0,2,4)), count=c(4500,1500,2600,4000,800,200,1500,50,20), machine=gl(n=3,k=3,length=9,labels=c("A","B","C"))) The following graph can be produced using either of these scripts: ggplot(data=sdf,aes(x=hours,y=count,group=machine,fill=machine))+ geom_area(data=sdf[sdf$machine=="A",])+ geom_area(data=sdf[sdf$machine=="B",])+ geom_area(data=sdf[sdf$machine=="C",]) ggplot(data=sdf,aes(x=hours,y=count,group=machine

AmChart legend in one line

只愿长相守 提交于 2019-12-22 09:26:14
问题 I'm trying to get AmChart chart legends into one line, but without luck. Legends are separated (one for line). Actual settings for from documentation http://docs.amcharts.com/3/javascriptcharts/AmLegend is following. "legend": { "equalWidths": false, //"periodValueText": "total: [[value.sum]]", "position": "bottom", "valueAlign": "left", "labelWidth": 100, "valueWidth": 200, //"width": 100, "align": "center" }, I Would like to ask how to get all chart legends into one line? Many Thanks for

Grand Totals in HighCharts Pie Chart Legend

自古美人都是妖i 提交于 2019-12-22 08:38:20
问题 Is there a way for me to get a grand total at the end of my value column in my legend? Here is the code for my legend right here as well as the fiddle wtih it broken into two columns for the name and value of the data[] set. legend: { enabled: true, layout: 'vertical', align: 'right', width: 220, verticalAlign: 'top', borderWidth: 0, useHTML: true, labelFormatter: function() { return '<div style="width:200px"><span style="float:left">' + this.name + '</span><span style="float:right">' + this

Plot issues - legend bar scale, breaks, legend, decimals

末鹿安然 提交于 2019-12-22 06:50:12
问题 I want to plot a bunch of rasters and I created a code to adjust breaks for each one and plot them trough a for loop. But i'm getting a problematic color scale bar, and my efforts haven't being effective to solve that. Example: I have precipitation ranging from 0 to 11.000...but most part of the data is between 0 and 5.000... and very few up to 11.000. So I need to change the breaks to capture this variation... more breaks where I have more data. Then I created a breaks object for that. But

How to link plotly traces for legend and colour selection?

徘徊边缘 提交于 2019-12-21 18:00:09
问题 Problem I am migrating a number of ggplot / ggvis plots to plotly in a shiny application. There is an issue I've encountered regarding the linking of traces. I want to be able to show/hide traces by group on the legend, which is shared between related data frames. Minimal working example # load libraries library(dplyr) library(plotly) library(viridis) # contrived data to represent actual data points df1 <- data.frame(x = rnorm(100), y = rnorm(100), group = rep(c("G1", "G2", "G3", "G4"), 25))

Two geom_points add a legend

拈花ヽ惹草 提交于 2019-12-17 15:58:20
问题 I plot a 2 geom_point graph with the following code: source("http://www.openintro.org/stat/data/arbuthnot.R") library(ggplot2) ggplot() + geom_point(aes(x = year,y = boys),data=arbuthnot,colour = '#3399ff') + geom_point(aes(x = year,y = girls),data=arbuthnot,shape = 17,colour = '#ff00ff') + xlab(label = 'Year') + ylab(label = 'Rate') I simply want to know how to add a legend on the right side. With the same shape and color. Triangle pink should have the legend "woman" and blue circle the

How to add data table with legend keys to a MS Chart in C#?

陌路散爱 提交于 2019-12-17 07:55:34
问题 There are 2 lists called listversion & MIN_list . Using values of these list I have created a line chart. Everything is work fine. But I am wondering whether it is possible to add a data table with legend keys in to the chart like MS Excel. chart.Series.Clear(); chart.ChartAreas[0].AxisX.Title = "Version"; chart.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Arial", 12, FontStyle.Regular); chart.ChartAreas[0].AxisY.Title = "Time"; chart.ChartAreas[0].AxisY.TitleFont = new System