bar-chart

ggplot2 alternatives to fill in barplots, occurence of factor in multiple rows

谁说我不能喝 提交于 2020-01-16 17:20:05
问题 I'm pretty new to R and I have a problem with plotting a barplot out of my data which looks like this: condition answer 2 H 1 H 8 H 5 W 4 M 7 H 9 H 10 H 6 H 3 W The data consists of 100 rows with the conditions 1 to 10, each randomly generated 10 times (10 times condition 1, 10 times condition 8,...). Each of the conditions also has a answer which could be H for Hit, M for Miss or W for wrong. I want to plot the number of Hits for each condition in a barplot (for example 8 Hits out of 10 for

Using barplot in R studio

*爱你&永不变心* 提交于 2020-01-16 07:49:33
问题 when I try this code for barplot ( L$neighbourhood is the apartment neighbourhood in Paris for example, Champs-Elysées, Batignolles, which is string data, and L$price is the numeric data for apartment price). barplot(L$neighbourhood, L$price, main = "TITLE", xlab = "Neighbourhood", ylab = "Price") But, I get an error: Error in barplot.default(L$neighbourhood, L$price, main = "TITLE", xlab = "Neighbourhood", : 'height' must be a vector or a matrix We cannot use string data as an input in

Force / edit axis values in latticeExtra

你。 提交于 2020-01-16 01:16:52
问题 I'm using one dataset where the variable present in X has only two possible values - 2009 or 2010. 2009,01,52.4 2009,01,49.5 2009,01,53.2 2009,01,48.2 2009,01,53.9 2009,01,42.8 2009,01,56.4 2009,01,57 2009,01,50.3 2009,01,57.4 2009,01,45.2 2009,01,55 2009,01,47.1 2009,01,42.2 2009,01,57.1 2009,01,51.7 2009,01,56.8 2009,01,56.9 2009,01,55 2009,01,52.9 2009,01,52.9 2009,01,57 2009,01,45 2009,01,52.8 2009,01,52 2009,01,55.1 2009,01,53.3 2009,01,55.2 2009,01,53.2 2009,01,56.9 2009,01,55.9 2009,02

How to create a bar chart in D3?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-15 11:16:47
问题 I need help creating a bar chart, just a normal bar chart. I have 5 objects, each with their own 10 fields. I want to create a side-by-side bar layout where the x axis labels are the 10 fields. Above the ith field should be a rectangle for each 5 object with each height corresponding to that objects data for that field. Each object has its own distinctive color. I've spend 4+ hours and I've got nothing. Google reveals nothing that helps. Note: the rectangles of the bar chart should be

How to create a bar chart in D3?

坚强是说给别人听的谎言 提交于 2020-01-15 11:15:33
问题 I need help creating a bar chart, just a normal bar chart. I have 5 objects, each with their own 10 fields. I want to create a side-by-side bar layout where the x axis labels are the 10 fields. Above the ith field should be a rectangle for each 5 object with each height corresponding to that objects data for that field. Each object has its own distinctive color. I've spend 4+ hours and I've got nothing. Google reveals nothing that helps. Note: the rectangles of the bar chart should be

How to reshape data for a stacked barchart using R lattice [duplicate]

只谈情不闲聊 提交于 2020-01-15 11:15:12
问题 This question already has answers here : Reshaping data.frame from wide to long format (7 answers) Closed 5 years ago . I have a bunch of data in a table (imported from csv) in the following format: date classes score 9/1/11 french 34 9/1/11 english 34 9/1/11 french 34 9/1/11 spanish 34 9/2/11 french 34 9/2/11 english 34 9/3/11 spanish 34 9/3/11 spanish 34 9/5/11 spanish 34 9/5/11 english 34 9/5/11 french 34 9/5/11 english 34 Ignore the score column, it's not important. I need a tally of the

How to add main title and manipulating axis labels in ggplot2 in Rstudio

时光怂恿深爱的人放手 提交于 2020-01-14 04:26:07
问题 I am new to R and I am using Rstudio. I have a ggplot2 R script for drawing a bar plot (something same as this) that I have created it by others help but it has two errors that seems super simple but I can not solve them: 1) in the x axis label it must be the Function Class , but it is FunctionClass (without space). and when I add space, it shows this error -> : Error : unexpected symbol in "p <- ggplot(data=dat, aes(x=Function Class" 2) I can not add the Main Title to the plot I have this

Floating bar chart with dates as the plotted values in r

纵然是瞬间 提交于 2020-01-13 19:20:08
问题 I want to plot the range of dates where a particular object is "active", as shown below: This example is taken from Wikipedia. Here is the data: df1 <- data.frame( name = c("Eazy-E", "DJ Yella", "Dr. Dre", "Ice Cube", "Arabian Prince", "MC Ren"), from = as.Date(c("01/01/1986", "01/01/1986", "01/01/1986", "01/01/1986", "01/01/1986","02/01/1988"), "%m/%d/%Y"), to = as.Date(c("08/01/1991", "08/01/1991", "07/01/1991", "12/01/1989", "07/01/1988", "08/01/1991"),"%m/%d/%Y")) df1 name from to 1 Eazy

how to change the order of factor plot in seaborn

雨燕双飞 提交于 2020-01-11 08:11:30
问题 My data looks like this: m=pd.DataFrame({'model':['1','1','2','2','13','13'],'rate':randn(6)},index=['0', '0','1','1','2','2']) I want to have the x-axis of factor plot ordered in [1,2,13] but the default is [1,13,2]. Does anyone know how to change it? Update : I think I have figured it out in the following way, but maybe there is a better way by using an index to do that? sns.factorplot('model','rate',data=m,kind="bar",x_order=['1','2','13']) 回答1: Your update to the post shows the correct

ggplot displaying expression in x axis

妖精的绣舞 提交于 2020-01-11 02:34:44
问题 Below, I have R code that plots a grouped bar plot. group_name = c('A_1x', 'A_1x', 'A_2x', 'A_2x', 'A_3x', 'A_3x', 'A_4x', 'A_4x') mydata2 <- data.frame(mygroup = group_name, mysubgroup = factor(c("Yes", "No"), levels = c("Yes", "No")), value = c(60,40,90,10,55,45,88,12)) ggplot(mydata2, aes(mygroup, value, fill = mysubgroup)) + geom_bar(position = "dodge", width = 0.5, stat = "identity")+ coord_flip() Currently, the plot looks like below. However, I want to show expressions in the x axis as