legend-properties

Changing the text in legend in ggplot map R Studio

穿精又带淫゛_ 提交于 2019-12-08 00:32:35
问题 I am trying to create a US map filled with heat level of flu diseases. I am having 2 issues: I couldn't change the variable text in the legend. The order of the legend is wrong. 1->10->2->... Here is the code. library(maps) library(ggplot2) # Get all states data all_states <- map_data("state") # Clean the data subHeat <- subset(q4_heatMap, WEEK=="4") region <- tolower(subHeat$STATENAME) stateHeat <- subHeat$ACTIVITY.LEVEL stateHeat <- gsub('Level ', '', stateHeat) usHeat <- data.frame(region

R corrplot colorlegend change range

試著忘記壹切 提交于 2019-12-07 08:34:02
问题 I am trying to plot in R a correlation matrix using the corrplot package. My problem is that the range of min and max correlation coefficients of the entire matrix is (-0.2,0.2). I plot the matrix with corrplot and I use a custom colorRampPalette , say col1<-colorRampPalette(c('red','yellow','green','blue')) for the colormap of the legend, so I set col=col1(10) , and I set cl.lim=c(-0.2,0.2) . When I see the plot however the colorlegend appears from -0.2 to 0.2 but with just 2 colors, instead

Changing the text in legend in ggplot map R Studio

混江龙づ霸主 提交于 2019-12-06 09:24:41
I am trying to create a US map filled with heat level of flu diseases. I am having 2 issues: I couldn't change the variable text in the legend. The order of the legend is wrong. 1->10->2->... Here is the code. library(maps) library(ggplot2) # Get all states data all_states <- map_data("state") # Clean the data subHeat <- subset(q4_heatMap, WEEK=="4") region <- tolower(subHeat$STATENAME) stateHeat <- subHeat$ACTIVITY.LEVEL stateHeat <- gsub('Level ', '', stateHeat) usHeat <- data.frame(region,stateHeat) # Merge two set of dataframes heatTotal <- merge(all_states, usHeat,by="region") # heatColor

AmChart legend in one line

只谈情不闲聊 提交于 2019-12-06 03:50:37
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 any advice. you can try legend{ "maxColumns": 1, } I think it auto resize follows width of div. Btw, You

How to add a custom legend for geom_hline

时光总嘲笑我的痴心妄想 提交于 2019-12-06 00:10:12
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(labels = percent_format())+ theme(legend.position="right", legend.title = element_blank(), strip.text

Printing too big legend box in RStudio

孤者浪人 提交于 2019-12-05 22:24:44
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 to run some of the sample codes provided in R I also get weired looking plots. For instance, my plot

Grand Totals in HighCharts Pie Chart Legend

会有一股神秘感。 提交于 2019-12-05 14:59:27
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.y + '%</span></div>'; }, title: { text: 'Primary', style: { fontWeight: 'bold' } } } id like the column

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

旧街凉风 提交于 2019-12-05 10:31:44
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 when I plot the raster, the scale color bar gets awful, very messy... #get predictors (These are a way

How to link plotly traces for legend and colour selection?

非 Y 不嫁゛ 提交于 2019-12-04 09:57:04
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)) # contrived data to represent theoretical relationship df2 <- data.frame(x = c(rep(-2, 4), rep(2, 4)),

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

扶醉桌前 提交于 2019-12-03 08:35:08
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(data = spottingIntensityByMonth, mapping = aes(x = yearMonth, y = nClassificationsPerDayPerSpotter) ) +