bar-chart

Frequency density barplot of categorical variable

耗尽温柔 提交于 2019-12-25 06:47:55
问题 I'd like to plot a barplot of frequency density of the following ordered categorical data: summary(ACC[EA$TYPE=="A"]) NG SG LG MG HG 2 25 36 17 0 If I plot: plot(ACC[EA$TYPE=="A"]) I get: But I'd like to divide all the values by the total to get a frequency density: Ie. plot(ACC[EA$TYPE=="A"]/sum(as.numeric(ACC[EA$TYPE=="A"]))) but that doesn't work. Any tips? Cheers, 回答1: The default plotting function for a factor is barplot . So if you want a different graph, it may be easier to directly

r stacked bargraph with colors representing values

懵懂的女人 提交于 2019-12-25 05:35:37
问题 I'm looking to make a stacked barchart with colors representing values from a separate data column as well as add an accurate color bar using just the base graphics in R . There is one other post about this but it is pretty disorganized and in the end doesn't help me answer my question. # create reproducible data d <- read.csv(text='Day,Location,Length,Amount 1,4,3,1.1 1,3,1,.32 1,2,3,2.3 1,1,3,1.1 2,0,0,0 3,3,3,1.8 3,2,1,3.54 3,1,3,1.1',header=T) # colors will be based on values in the

How I get a facet_grid plot, with free scales AND barplots, with ggplot2?

非 Y 不嫁゛ 提交于 2019-12-25 03:15:48
问题 I'm (re)learning ggplot2 and trying to get this particular plot, which is proving quite evasive. Earlier I found this question, which was useful, but not everything I need. This is more or less what you get using the accepted answer to that Q: ## Packages & data: require(dplyr) set.seed(0) df <- data.frame(categ=c("A", "B", "C"), V1=rpois(3, 20), V2=rnorm(3, 100, 40), V2=runif(3)) %>% gather(Var, X, 2:4) ## Se below in "Example data" for how to get this example p <- ggplot(df, aes(categ, X,

how to add proportion label on the stacked bar chart in python bar chart

馋奶兔 提交于 2019-12-25 03:08:01
问题 I have plotted stacked bar chart and want to add text indicating its proportion on the bar but do not know how I can add those labels on. My codes are, tps = df3[df3['Action Type_new']!='NA'].pivot_table(values=['Column'], index='year', columns='Action Type_new', aggfunc='sum') tps = tps.div(tps.sum(1), axis=0) tps.plot(kind='bar', stacked=True) and my tps looks like, (it is pivot table so, it has multi index) MultiIndex(levels=[['Column'], ['Less Severe', 'Severe']], labels=[[0, 0], [0, 1]],

PhpExcel Bar Chart

此生再无相见时 提交于 2019-12-25 02:59:31
问题 I want to change the color of each bar in my bar chart , the chart is like: There are four products product 1 product 2 product 3 product 4 There are two bars for each product, one is total value and one is overall value. Total value should have Black color. overall value should according to its product. Right now its coming only two colors Blue for total value red for overall value. So please help me for creating such bar chart who has different colors for different product. Thanks in

The most elegant way to modify messy and overlapping date labels below x axis? (Seaborn, barplot)

送分小仙女□ 提交于 2019-12-24 23:29:55
问题 df (Pandas DataFrame) has two columns: Date (as datetime64) and Amount (as float). I plot the values from Amount column against time, using barplot: sns.barplot(x="Date", y="Amount", data=df) plt.show() However, the date labels are a terrible mess (see picture). What would be an elegant way of dealing with this in Pandas? I'm considering removing month and year from the label, or rotating the labels 90 degrees. How would these be done, or is there a better option? Thank you. 回答1: I would do

Add a jfree bar chart into a scroll pane

烈酒焚心 提交于 2019-12-24 21:23:27
问题 I have a JFree Bar Chart. the dataset is populated using DefaultCategoryDataset , There may be situations when the values on both the domain and range axis are such that these values are not very clearly visible. I need something like a scrollPane into which the chart can be added. But it looks like the ChartPanel cannot be added into a JScrollPane Is there any way of doing this ? Thanks Bhavya 回答1: You can use setLowerMargin() and/or getUpperMargin() on the relevant CategoryAxis to improve

Flot - bar chart with individual colors and labels

大憨熊 提交于 2019-12-24 20:28:20
问题 I use flot to display simple bar charts. I have single dataset like [ [0,5], [1,6], [2,3], [4,1] ] and I am using this simple code: myChart = $.plot($('#graphFlot'), [{ data: mdata, bars: { show: true, fill: 0.9 } }] ); Now I would like to display various colors and labels for each bar. Example bar chart here is how it should look like. I've browsed through many examples and documentation and still do not know how to set this. Is this possible? 回答1: Put each bar in its own series and give

How do I get a chart for a count of values in 3 bar chart in Excel?

跟風遠走 提交于 2019-12-24 18:31:51
问题 I have a survey that is sent out to customer. The survey has 3 questions with 3 options to choose from: Not Satisfied Satisfied and Very Satisfied. The results data looks something like this: Question 1 Question 2 Question 3 Date Not Satisfied Satisfied Satisfied 04/07/2017 Satisfied Satisfied Satisfied 04/07/2017 Satisfied Satisfied Very Satisfied 04/07/2017 Not Satisfied Satisfied Satisfied 04/07/2017 Very Satisfied Satisfied Satisfied 04/07/2017 Not Satisfied Very Satisfied Satisfied 05/07

ggplot2: Using `fill = …` in aes(..) and geom_bar(..). The colors repeat

雨燕双飞 提交于 2019-12-24 17:25:13
问题 Here is a barplot with ggplot : library(ggplot2) ggplot(subset(dat, Gene=='3_RH2B'), aes(x=Morpho, y=Weights, fill=Model2)) + geom_bar(stat='identity') + ggtitle('RH2B') My problem is that the colors repeat instead of forming one big block. I would like that each bar is formed by three blocks of color corresponding to the three levels of the variable dat$Model2 . How can I achieve this? Why does ggplot create this graph and not directly the one I'd like? Here is the data.frame dat : Gene