bar-chart

Python: Barplot with colorbar

笑着哭i 提交于 2019-12-21 19:36:31
问题 I'm trying to make a bar plot with a color bar, each bar's hight is one variable (y) and each bar should have a color depending on another variable (c). What I've got to is this (simple example): data_x = [0,1,2,3] data_hight = [60,60,80,100] data_color = [1000,500,1000,900] data_color = [x / max(data_color) for x in data_color] fig, ax = plt.subplots(figsize=(15, 4)) my_cmap = plt.cm.get_cmap('GnBu') colors = my_cmap(data_color) rects = ax.bar(data_x, data_hight, color=colors) CS = plt

Python: Barplot with colorbar

只谈情不闲聊 提交于 2019-12-21 19:35:50
问题 I'm trying to make a bar plot with a color bar, each bar's hight is one variable (y) and each bar should have a color depending on another variable (c). What I've got to is this (simple example): data_x = [0,1,2,3] data_hight = [60,60,80,100] data_color = [1000,500,1000,900] data_color = [x / max(data_color) for x in data_color] fig, ax = plt.subplots(figsize=(15, 4)) my_cmap = plt.cm.get_cmap('GnBu') colors = my_cmap(data_color) rects = ax.bar(data_x, data_hight, color=colors) CS = plt

Problem placing error bars at the center of the columns in ggplot()

守給你的承諾、 提交于 2019-12-21 17:54:32
问题 I am having a problem with my bar chart- the error bars just appear on the corner of the columns of the grouping variable rather than on them in a centralised way. The code I am using is this: a <- data.frame (Cond = c("In", "In", "Out", "Out"), Temp = c("Hot", "Cool", "Hot", "Cool"), Score = c(.03, -.15, 0.84, 0.25), SE = c(.02, .08, .14, .12)) a.bar <- ggplot (data = a, aes(x = Cond, y = Score, fill = Temp)) + theme_bw() + theme(panel.grid = element_blank ()) + coord_cartesian (ylim = c(-0

Constant width in ggplot barplots

☆樱花仙子☆ 提交于 2019-12-21 12:14:48
问题 How to make the width of bars and spaces between them fixed for several barplots using ggplot , having different number of bars on each plot? Here is a failed try: m <- data.frame(x=1:10,y=runif(10)) ggplot(m, aes(x,y)) + geom_bar(stat="identity") ggplot(m[1:3,], aes(x,y)) + geom_bar(stat="identity") Adding width=1 to geom_bar(...) doesn't help as well. I need the second plot automatically to have less width and the same bar width and spaces as the first one. 回答1: Edit: It appears the OP

Use d3 log scale instead of linear scale

假装没事ソ 提交于 2019-12-21 07:33:48
问题 I'm trying to do a chart based on http://mbostock.github.com/d3/talk/20111116/bar-hierarchy.html, the only difference being that I'd like to use a log scale for the x-axis. Here's my fiddle: http://jsfiddle.net/JhDVC/5/ As you can see, the x-axis is defined at line 4: x = d3.scale.linear().range([0, w]), If I change it for x = d3.scale.log().range([0, w]), Then it doesn't work (nothing is rendered), throwing these error messages: Error: Invalid value for <rect> attribute width="NaN" Changing

Bar Chart in java

余生长醉 提交于 2019-12-21 05:48:07
问题 I want to change the height of each bar (for example 10 for red part and 20 for blue part). But when I increase the height value it will increase the chart from bottom whereas I want the change to top! Do you know what is wrong with it? import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import javax.swing

Overlayed Circular multiple barcharts in R

大憨熊 提交于 2019-12-20 14:10:28
问题 The following is my data: chr <- rep (1:4, each = 200) position <- c(1:200, 1:200, 1:200, 1:200) v1bar <- rnorm(800, 10, 2) v2bar <- rnorm(800, 10, 2) v3bar <- rnorm(800, 10, 2) mydata <- data.frame (chr, position, v1bar, v2bar, v3bar) I want to create multiple circular bar charts with the x value = pos and y value = v1bar, v2bar, v3bar (all three will be in successive circles). Each circle is divided to chr. Thus each circle has "pie slice". I am not sure what such graph is known as and

R highcharts multiple stacked bar chart

二次信任 提交于 2019-12-20 04:55:28
问题 I want to plot a multiple stacked bar chart, but I don't know how to combine the r code. Closing Date Non Current Assets Current Assets Non Current Liabilities 2 2013/12 13637344 13078654 9376243 3 2014/12 14075507 12772388 8895126 4 2015/12 14578093 14226181 9715914 5 2016/12 10911628 10205708 9810157 6 2017/12 10680998 10950779 13493110 Current Liabilities 2 5075985 3 4963856 4 5992229 5 8859263 6 4094183 I can plot multiple bar chart by: highchart() %>% hc_chart(type = "column") %>% hc

Highlight a single “bar” in ggplot

醉酒当歌 提交于 2019-12-20 03:41:48
问题 i'd like to choose colors and fill patterns for individual bars in a bar graph (Highlight a single "bar") The bars, that i'd like to fill in another color are "Str" and "RB" ggplot(GZ.mean, aes(x=Group.1, y=B)) +theme_bw(base_size=20, base_family="Times")+ geom_bar(stat="identity",colour="black", width=.6, position = "dodge", ,fill="gainsboro") +geom_errorbar(my.limits, width=0.2) + theme(axis.text.x=element_text(family="Times", colour="black", size=rel(1.2), angle=30, hjust=1, vjust=1))+

grouped barplot: order x-axis & keep constant bar width, in case of missing levels

亡梦爱人 提交于 2019-12-20 03:19:23
问题 Here is my script (example inspired from here and using the reorder option from here): library(ggplot2) Animals <- read.table( header=TRUE, text='Category Reason Species 1 Decline Genuine 24 2 Improved Genuine 16 3 Improved Misclassified 85 4 Decline Misclassified 41 5 Decline Taxonomic 2 6 Improved Taxonomic 7 7 Decline Unclear 10 8 Improved Unclear 25 9 Improved Bla 10 10 Decline Hello 30') fig <- ggplot(Animals, aes(x=reorder(Animals$Reason, -Animals$Species), y=Species, fill = Category))