pie-chart

beautiful Pie Charts with R

半世苍凉 提交于 2019-11-27 00:02:42
问题 Let's say I have this simple data: mydata <- data.frame(group=c("A", "B", "0", "AB"), FR=c(20, 32, 32, 16)) If I want to create a pie chart from this dataframe I can do: with(mydata,pie(FR, labels=paste0(as.character(group), " ", FR, "%"), radius=1)) It's quite simple but acceptable. How can I get something similar with ggplot2 or lattice? After much trial and error I've got ggplot(mydata, aes(x = factor(1), y=FR,fill=factor(group)) ) + geom_bar(width = 1,stat="identity")+coord_polar(theta =

JavaFX Pie Chart - Overlapping Labels & Missing Labels

大兔子大兔子 提交于 2019-11-26 22:06:22
问题 I have a chart that looks like this: Labels E and A are overlapping and Label D is missing. Label F value is 0 so I am not surprised it is missing. Here are the values for the labels: ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("A", 0.80), new PieChart.Data("B", 9.44), new PieChart.Data("C", 89.49), new PieChart.Data("D", 0.08), new PieChart.Data("E", 0.18), new PieChart.Data("F", 0.0)); I have tried: .chart{ -fx-background-color:

Label outside arc (Pie chart) d3.js

血红的双手。 提交于 2019-11-26 21:39:38
I'm new to d3.js and I"m trying to make a Pie-chart with it. I have only one problem: I can't get my labels outside my arcs... The labels are positioned with arc.centroid arcs.append("svg:text") .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; }) .attr("text-anchor", "middle") Who can help me with this? I can solve that problem - with trigonometry :). See fiddle: http://jsfiddle.net/nrabinowitz/GQDUS/ Basically, calling arc.centroid(d) returns an [x,y] array. You can use the Pythagorean Theorem to calculate the hypotenuse, which is the length of the line from the

nvd3 piechart.js - How to edit the tooltip?

强颜欢笑 提交于 2019-11-26 18:54:36
I'm using nvd3's piechart.js component to generate a piechart on my site. The provided .js file includes several var's, as follows: var margin = {top: 30, right: 20, bottom: 20, left: 20} , width = null , height = null , showLegend = true , color = nv.utils.defaultColor() , tooltips = true , tooltip = function(key, y, e, graph) { return '<h3>' + key + '</h3>' + '<p>' + y + '</p>' } , noData = "No Data Available." , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') ; In my in-line js, I've been able to override some of those variables, like this (overriding showLegend and margin): var chart

d3.js spreading labels for pie charts

社会主义新天地 提交于 2019-11-26 17:51:24
问题 I'm using d3.js - I have a pie chart here. The problem though is when the slices are small - the labels overlap. What is the best way of spreading out the labels. http://jsfiddle.net/BxLHd/16/ Here is the code for the labels. I am curious - is it possible to mock a 3d pie chart with d3? //draw labels valueLabels = label_group.selectAll("text.value").data(filteredData) valueLabels.enter().append("svg:text") .attr("class", "value") .attr("transform", function(d) { return "translate(" + Math.cos

R::ggplot2::geom_points: how to swap points with pie charts?

限于喜欢 提交于 2019-11-26 17:25:49
问题 I would like to plot pie charts in two dimensions to show the composition of each point in terms of their composite "groups." So far, I'm using label repel to label to highest scoring points but it is still not great. I've looked around and I haven't seen what I'm looking for. ggplot(data=aggtmp2,aes(x=cluster,y=x,color=groups,shape=dataset)) + geom_jitter() + facet_grid(datasubset~.) + geom_text_repel(data=aggtmp2[aggtmp2$xnorm>.925,],aes(label=groups),size=2) > str(aggtmp2) 'data.frame':

Pie charts in ggplot2 with variable pie sizes

只愿长相守 提交于 2019-11-26 16:46:22
问题 I've tried various ways to get a facet_grid of pie charts in ggplot2 to vary width/radii according to another variable (strength). geom_bar accepts width=0.5 as a parameter but it is ignored once coord_polar is added. Adding width=0.5 to the ggplot aes or adding a aes to geom_bar doesn't work. I can't see any other relevant options for coord_polar . What's the easiest way to do this? The code below makes a nice grid of pie charts but doesn't change the sizes of the pie charts. What am I

ggplot, facet, piechart: placing text in the middle of pie chart slices

浪子不回头ぞ 提交于 2019-11-26 11:21:35
I'm trying to produce a facetted pie-chart with ggplot and facing problems with placing text in the middle of each slice: dat = read.table(text = "Channel Volume Cnt AGENT high 8344 AGENT medium 5448 AGENT low 23823 KIOSK high 19275 KIOSK medium 13554 KIOSK low 38293", header=TRUE) vis = ggplot(data=dat, aes(x=factor(1), y=Cnt, fill=Volume)) + geom_bar(stat="identity", position="fill") + coord_polar(theta="y") + facet_grid(Channel~.) + geom_text(aes(x=factor(1), y=Cnt, label=Cnt, ymax=Cnt), position=position_fill(width=1)) The output: What parameters of geom_text should be adjusted in order to

R + ggplot2 => add labels on facet pie chart [duplicate]

你说的曾经没有我的故事 提交于 2019-11-26 11:09:24
问题 This question already has answers here : ggplot, facet, piechart: placing text in the middle of pie chart slices (4 answers) Closed 4 years ago . I want to add data labels on faceted pie char. Maybe someone can can help me. My data: year <- c(1,2,1,2,1,2) prod <- c(1,1,2,2,3,3) quantity <- c(33,50,33,25,34,25) df <- data.frame(year, prod, quantity) rm(year, prod, quantity) Code: library(ggplot2) # center\'s calculated by hand centr2 <- c(16, 25, 49, 62.5, 81, 87.5) ggplot(data=df, aes(x

ggplot2 pie and donut chart on same plot

允我心安 提交于 2019-11-26 09:19:26
问题 I am trying to replicate this with R ggplot. I have exactly the same data: browsers<-structure(list(browser = structure(c(3L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 5L, 5L, 4L), .Label = c(\"Chrome\", \"Firefox\", \"MSIE\", \"Opera\", \"Safari\"), class = \"factor\"), version = structure(c(5L, 6L, 7L, 8L, 2L, 3L, 4L, 1L, 10L, 11L, 9L), .Label = c(\"Chrome 10.0\", \"Firefox 3.5\", \"Firefox 3.6\", \"Firefox 4.0\", \"MSIE 6.0\", \"MSIE 7.0\", \"MSIE 8.0\", \"MSIE 9.0\", \"Opera 11.x\", \"Safari 4.0\", \