bar-chart

Grouped barplot in ggplot2 in R

你说的曾经没有我的故事 提交于 2019-12-12 13:04:31
问题 I would like to make a grouped bar plot. An example of my data is as follows: site code year month gear total value 678490 2012 3 GL 13882 678490 2012 4 GL 50942 678490 2012 5 GL 54973 678490 2012 6 GL 63938 678490 2012 7 GL 23825 678490 2012 8 GL 8195 678490 2012 9 GL 14859 678490 2012 9 RT 3225 678490 2012 10 GL 981 678490 2012 10 RT 19074 678490 2012 11 SD 106384 678490 2012 11 RT 2828 678490 2012 12 GL 107167 678490 2012 12 RT 4514 There are 17 site code options, four year options, twelve

Bar chart not working in AchartEngine

我怕爱的太早我们不能终老 提交于 2019-12-12 12:23:05
问题 I am trying to create Bar Chart using AchartEngine but various things doesn't work for me.. 1) Unable to show Grid. 2) Unable to remove category series title i.e "Bar Graph". 3) It's not showing bars as it should show. 4) By Default white color background is visible. is it possible to provide space between each bars?? Bar Chart Code CategorySeries series = new CategorySeries("Bar Graph"); for (int i = 0; i < availCatList.size(); i++) series.add(availCatList.get(i), mTotal.get(i));

Combining position_dodge and position_fill in ggplot2

痴心易碎 提交于 2019-12-12 11:40:52
问题 What I would like to do is use both the position = "fill" and the position = "dodge" arguments of geom_bar() at the same time somehow. Using some sample data set.seed(1234) df <- data.frame( Id = rep(1:10, each = 12), Month = rep(1:12, times = 10), Value = sample(1:2, 10 * 12, replace = TRUE) ) I'm able to create the following graph df.plot <- ggplot(df, aes(x = as.factor(Month), fill = as.factor(Value))) + geom_bar(position = "fill") + scale_x_discrete(breaks = 1:12) + scale_y_continuous

How can I display the bar value on top of each bar on matplotlib?

一曲冷凌霜 提交于 2019-12-12 11:34:56
问题 I read a couple of questions like mine, but no one seems to have the same problem that I'm experiencing. import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt facebook_users = [10, 14, 19, 17, 17, 13, 10] twitter_users = [10, 18, 22, 17, 15, 11, 7] linkedin_users = [4, 10, 20, 18, 20, 17, 11] group = ['13 - 17', '18 - 24', '25 - 34', '35 - 44', '45 - 54', '55 - 65', '65+'] mpl.rcParams['axes.prop_cycle'] = mpl.cycler(color=["#3B5998", "c", "grey"]) def bar_group(classes,

Manipulating x axis tick labels in matplotlib

假装没事ソ 提交于 2019-12-12 10:47:09
问题 I have noticed that when I have 5 or less bars of data in my bar graph the x-axis automatically adds in extra ticks: What I want is something like this: Is there any way I can force matplotlib to generate just one tick label per bar for the first graph? 回答1: The bar method takes a parameter align . Set this parameter as align='center' . align aligns the bars on the center of the x values we give it, instead of aligning on the left side of the bar (which is the default). Then use the xticks

Annotate stacked barplot matplotlib and pandas [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-12 09:06:49
问题 This question already has an answer here : stack bar plot in matplotlib and add label to each section (and suggestions) (1 answer) Closed last year . I have a simple Data Frame that stores the results of a survey. The columns are: | Age | Income | Satisfaction | all of them contains values between 1 and 5 (categorical). I managed to generate a stacked barplot that shows distribution of Satisfaction values across people of different age. The code is: #create a random df data = [] for i in

geom_text on only top part of stacked bar plot

▼魔方 西西 提交于 2019-12-12 08:57:04
问题 I would like to have labels on only the top part of my stacked bar plot. Here is my data frame: #create data frame building <- c("Burj \nKhalifa", "Zifeng \nTower", "Bank of \nAmerica Tower", "Burj Al Arab", "Emirates \nTower One", "New York \nTimes Tower", "Emirates \nTower Two", "Rose Rayhaan \nby Rotana", "The \nPinnacle", "Minsheng \nBank Building") occupiable<- c(585, 317, 235, 198, 241, 220, 213, 237, 265, 237) nonoccupiable <- c(244, 133, 131, 124, 113, 99, 97, 96, 95, 94) df.build <-

barplot in loop in R

筅森魡賤 提交于 2019-12-12 08:15:51
问题 Here is my question: #data 1: lab1 <- 1:10 group <- rep(1:3, each = length (lab1)) label <- rep(lab1, 3) avar <- rep(c(0, 1, 4, 5, 6, 8, 10, 11, 12, 13), 3) myd <- data.frame (group, label, avar) # data 2 fillcol <- rep(rnorm(length(lab1)-1, 0.5, 0.2), 3) group1 <- rep(1:3, each = length(fillcol)/3) # this variable will be used to fill color in bars filld <- data.frame(group1, fillcol) # now plotting par(mfrow = c(3, 1)) par(mar = c(2.5, 1, 2.5, 1)) #plot1 myd1 <- myd[myd$group ==1,] filld1 <

R Barchar does not work in For loop

流过昼夜 提交于 2019-12-12 06:57:00
问题 I am using barchart in For loop that goes on years, the barchart command is ok outside the loop, but inside - something goes wrong. Here is my code: for(i in 2006:2016){ htr2 = htr[htr$year==i , ] barchart(year ~ y_kayam , groups=shlav, htr2, auto.key = list(columns = 2) ) Sys.sleep(5) } Here is my data year vaada shlav tm38 y_kayam y_mevukash 2013 410 1 1 12.00 2013 410 2 1 12.00 2013 410 1 1 2013 410 1 1 8.00 15.00 2013 410 3 1 8.00 15.00 2013 410 1 8.00 15.00 2013 410 1 1 15.00 28.00 2013

Include values to the barplot and pie charts in R

爱⌒轻易说出口 提交于 2019-12-12 05:56:01
问题 I have data in this form: proprete.freq <- table(cnData$proprete) proprete.freq.genre <-table(cnData$genre,cnData$proprete) I am using these functions (barplot and pie) to plot the data: barplot(proprete.freq.genre, col = heat.colors(length(rownames(proprete.freq.genre))) , main="Proprete", beside = TRUE) pie(proprete.freq, col=rainbow(3), names.arg=avis, main="Propreté") Here is the result: Question : How to include the value just on top of the barplots and below the categorical variables