legend

ggplot2: How to add linebreak to horizontal legend

匆匆过客 提交于 2019-12-12 04:34:53
问题 Please consider the following R script (taken and slightly modified from here): require(ggplot2) x <- 1:10 y <- jitter(x^2) DF <- data.frame(x, y) p <- ggplot(DF, aes(x = x, y = y)) + geom_point() + stat_smooth(method = 'lm', aes(colour = 'linear')) + stat_smooth(method = 'lm', formula = y ~ poly(x,2), aes(colour = 'polynomial')) + stat_smooth(method = 'nls', formula = y ~ a * log(x) +b, aes(colour = 'logarithmic')) + stat_smooth(method = 'nls', formula = y ~ a*exp(b *x), aes(colour =

Change order of groups in stacked bar chart AND legend in R?

大城市里の小女人 提交于 2019-12-12 03:57:36
问题 I know that this kind of questions have already been asked, but I have already tried to apply it to my dataset for hours, but without success. Here is my dataframe > df prot X nr 1 unmodified same 68 2 1 Ac same 14 3 2 Ac same 7 4 3 Ac same 4 5 4 Ac same 3 6 5 Ac same 2 7 6 Ac same 1 8 7 Ac same 2 I tried two ways of adjusting the order of the groups, but in both cases the legend is exactly in the reverse order. How can I match the order of the groups in the plot with the one in the legend?

R: Plot grouped coordinates on world map

风流意气都作罢 提交于 2019-12-12 03:55:11
问题 I would like to plot a set of coordinates organized in studies/groups on a world map, specified in a legend. The dataset is organized as follows: AUTHORS | LAT | LONG The are multiple coordinates corresponding to one study that do not differ. Is it possible to plot numbers instead of symbols and link them to a legend? library(maps) library(mapdata) test<-data.frame(Authors=(letters[1:9]), LAT=(seq(10,90,by=10)), LONG=(seq(10,90,by=10))) map('worldHires') points(test$LONG,test$LAT, col="red")

Marker count in fusion table map

无人久伴 提交于 2019-12-12 03:03:27
问题 I went through these two links: first and second which explains how to add count of marker in fusion table map layer. I tried the same technique in my sample map but it didn't work. Actually i need the count of critical, optimal, normal transforers seperately and the total of all. Also i want to know that can I add these counts in map legend? 回答1: Over a year ago, I posted an answer with example code which is the same approach taken in your "first" link. https://stackoverflow.com/a/9778985.

R - order of legend ggplot

廉价感情. 提交于 2019-12-12 03:01:24
问题 I have the following data frame: Author<-c("University","Office", "School","University","Office", "School","University","Office", "School") Typ<-c("Text", "Text", "Text","Data", "Data","Data", "List", "List", "List") Number<-c("3","1","6","4","4","2","8","1","1") df<-data.frame(Typ,Author,Number) If I apply: ggplot(df, aes(x=Author, y=Number, fill=Typ)) + geom_bar(stat='identity') + coord_flip() then I get a stacked bar plot where the bars are orders in the order of the date frame, i.e. Text

Highcharts markers on legend and hover ONLY

可紊 提交于 2019-12-12 02:51:59
问题 I need to show highchart markers only on hover state and in the legend at all times. I don't want it to show on normal state in the chart. I searched for this and found this post which did not work for me Series markers disable on lines and enable on legend in Highchart 回答1: You can reset drawPoints function. Highcharts.Series.prototype.drawPoints = function() { }; Example: http://jsfiddle.net/11pLzk9m/1/ 来源: https://stackoverflow.com/questions/31997776/highcharts-markers-on-legend-and-hover

Moving the Y position of a legend in D3

ぃ、小莉子 提交于 2019-12-12 02:49:24
问题 I've made a legend for my choropleth map inspired off of this: http://bl.ocks.org/KoGor/5685876 The challenge is, I want to change the legend's location within my canvas/svg. var legend = svg.selectAll("g.legend") .data(ext_color_domain) .enter().append("g") .attr("class", "legend"); var ls_w = 20, ls_h = 20; legend.append("rect") .attr("x", 20) .attr("y", function(d, i){ return height - (i*ls_h) - 2*ls_h;}) .attr("width", ls_w) .attr("height", ls_h) .style("fill", function(d, i) { return

diverging size scale ggplot2

我只是一个虾纸丫 提交于 2019-12-12 00:46:36
问题 I am trying to map model/obs differences at locations in space. I have color mapped to the diff but I would also like to map size to diff. i'm currently mapping size to abs(diff) but it produces two different legends that I would like to combine. mapping size to diff creates small points for negative values and large points for positive values but I really only want the magnitude represented for over/under predictions. In case it makes a difference, I would also like the scales to be discrete

axes labels for 3 variables

房东的猫 提交于 2019-12-11 18:36:53
问题 My question is I want to plot a graph looking something like this Where I want to make a simple plot of points with x and y labels. This part is fine, but then like in the photo I would like to add another label on another side matching the same data points of the other two axis So if I have a simple data set like x y name 1 1 A 2 3 B 3 3 C How can I add the names A B and C on the top axis corresponding to the x,y points ? thanks. 回答1: If I understand right try df=data.frame(x=c(1,2,3),y=c(1

ggplot not adding legend. What am I missing? very new to R

你。 提交于 2019-12-11 18:14:05
问题 I'm plotting three samples with ggplot but it's not adding a legend for the samples. It's not spitting out any error message so I'm not sure where I'm going wrong. I'd really appreicate some guidance. I've tried to declare color for each sample for the legend manually but there is still no legend on the plot. df<-data.frame(samples$V1, samples$V2, samples$V3, samples$V4, samples$V5, samples$V6, samples$V7) CG_methplot <- ggplot(df, aes(x=samples$V1,))+ scale_x_continuous(breaks=number_ticks