FAQ Database Discussion Community

ggplot2: side by side barplot with one bar stacked and the other not

r,ggplot2,bar-chart
I am trying to create a barplot where for each category, two bars are plotted (side by side): one is for the "total", the other is stacked by subgroups. For example, in the following data frame, 'names' will be shown on x-axis. For each category in 'names', one bar will...

Bar Plot x-axis order in R ggvis

r,bar-chart,ggvis
I am experimenting to use ggvis for my daily report. One issue I came across is that for a dataset that I intended to plot x-axis as in the data order. However, the actual plot shows up in the alphabet order. Is there any hidden parameters to change x-axis order...

Grouped Stacked Bar Plot in R from Table Columns [closed]

r,bar-chart
I want to generate a plot looking like this: Could you give me a hint how top achieve that? I startet with: T1 <- c(23.2,34.5,76.3,65.8,12.6) T2 <- c(15.6,12.4,21.8,20,5.2) T3 <- c(15.6,12.4,21.8,20,5.2) A <- gl(5,1,5,labels=c("Mähen","Wenden","Schwaden","Pressen","Abtransport")) data <- cbind(T1,T2,T3) rownames(data) <- levels(A) barplot(x1,names.arg=levels(A)) barplot(x3,names.arg=levels(A)) #barplot(t(data),beside=F, ylim=c(0,100),legend.text=colnames(data), barplot(t(data),beside=F, legend.text=colnames(data),...

jQuery sparklines set colour of individual bar

jquery,bar-chart,sparklines
I am using jquery Sparklines to make cute little bar graphs however I want to only colour the last bar a different colour. The code below works, but it would be nice if I could colour the bars by the tooltip names rather than by value. Is there a way...

How to display the value of the bar on each bar with pyplot.barh()?

python,matplotlib,bar-chart
I generated a bar plot, how can I display the value of the bar on each bar? Current plot: What I am trying to get: My code: import os import numpy as np import matplotlib.pyplot as plt x = [u'INFO', u'CUISINE', u'TYPE_OF_PLACE', u'DRINK', u'PLACE', u'MEAL_TIME', u'DISH', u'NEIGHBOURHOOD'] y = [160,...

How can I set different colours for each bar in angular-chart.js?

javascript,angularjs,charts,bar-chart
I've looked at How to change colours for Angular-Chart.js, but it relates to colours for an entire (dataset), not a specific bar. What I'm looking for is a way to apply Different color for each bar in a bar chart; ChartJS to Angular. So, I've got a bar chart: <canvas...

Removing negative values from axis

java,javafx-8,bar-chart,linechart,axis-labels
I have a BarChart and a LineChart. The possible values go from negative(-) to positive(+). How would I only display the positive axis-labels? As in only remove the numbers. Should I make a custom Chart or is there an easier way?...

Change the form of an array (PHP)

php,arrays,bar-chart
I have a huge, complicated issue in my php app. Here are the details: I currently have this as my array (var dumped): array (size=6) 0 => string '11/04/15' (length=8) 1 => string '15/04/15' (length=8) 2 => string '19/04/15' (length=8) 3 => string '1' (length=1) 4 => string '1' (length=1)...

R barplot with very long names

r,ggplot2,label,bar-chart
I want to produce a barplot of 10 items stored in a data frame: df <- structure(list(v = structure(c(0.133177575198731, 0.048416489312887, 0.0323328322269662, 0.0257842168974815, 0.0207946396185765, 0.0157952295839215, 0.015414483430714, 0.0138292246981344, 0.0136598827935515, 0.0132108536143025 ), .Dim = 10L, .Dimnames = structure(list(c("HIPERTENSION ESENCIAL (PRIMARIA)", "RINOFARINGITIS AGUDA", "DIARREA Y GASTROENTERITIS DE PRESUNTO ORIGEN INFECCIOSO", "LUMBAGO NO ESPECIFICADO", "INFECCION...

Representing bars with different colors in matlab

matlab,bar-chart
i have a bar graph having three bars as follows x=[0.22,0.34,0.42] bar(x,0.1,'stacked') somenames={'IND Relation' ; 'DIS Relation' ; 'EQ Relation'} set(gca,'xticklabel',somenames) ylabel('F1') all the three bars are in blue color but i want to represent IND Relation with Brown color, DIS Relation with green color and EQ Relation with blue...

Horizontal barplot in ggplot2 with faces having different categories

r,ggplot2,bar-chart,facet
I have a data frame with ids, categories, and values, while I manage easily to have an horizontal dot-plot, with products grouped by category in distinct facets, when I try with a barplot, event categories with missing data show up. Any hint? Is it a bug or am I missing...

How to create stacked bar chart using C3 for string data?

bar-chart,c3
I am trying to created stacked bar chart using C3 chart. But i am facing problem as i am trying to plot a graph with string values. My data looks like this var data1=["Country", "Denmark", "India"] var data2=["Value", 1, 1] var X=["Item",'Item1','Item2] c3.generate({ data: { x:'Item', columns:[[data1],[data2]], type: 'bar' ,...

creating a grouped barplot in r that does'nt use counts

r,bar-chart
I am trying to create a barplot with the following data: https://www.dropbox.com/s/8xthu6aupp8c7ox/codeexampl.PNG?dl=0 I want the x-axis to show the elements (Sc, Y, La...) and for every element I want two bars next to each other. One for X13608g and one for X13608f with 48.3235 and 53.9796 as the y values....

Grouped Barplot with three measures

r,excel,ggplot2,bar-chart
I am trying to reproduce the following graph in R which is generated via Excel. The CSV file has following content: > myd type am tae tac 1 kA 81.73212 73.07151 26.92849 2 kI 78.87324 84.50704 15.49296 3 kL 82.52184 69.91262 30.08738 4 kS 82.67147 69.31411 30.68589 5 sA 81.67176...

Recreate bar chart without it remembering data

javafx,bar-chart
Task I have a BarChart which I have to fill with different data over and over again. The data must be in a predefined order. Of course I only want to change the data and not create a bar chart every time. Problem Once you have a category with a...

Empty space in MATLAB bar chart [duplicate]

matlab,plot,bar-chart
This question already has an answer here: White space on the right when using bar Matlab 2 answers I'm plotting a bar chart of 901 values using MATLAB R2015a: What is empty space in the end of plot (black box)? How can I remove it?...

Dimple.js barGap function not working

javascript,d3.js,charts,bar-chart,dimple.js
Below is a D3 and Dimple.js code, The Chart displays all objects. However, the bargaps are not changing and they display real thin. When I change the property barGap, it doesn't effect the chart at all. I am inserting the image at the bottom. <!DOCTYPE html> <html> <head> <meta charset="utf-8">...

ggplot reorder stacked bar plot based on values in data frame

r,ggplot2,bar-chart,stacked-chart
I am making stacked bar plots with ggplot2 in R with specific bar ordering about the y-axis. # create reproducible data library(ggplot2) d <- read.csv(text='Day,Location,Length,Amount 1,4,3,1.1 1,3,1,2 1,2,3,4 1,1,3,5 2,0,0,0 3,3,3,1.8 3,2,1,3.54 3,1,3,1.1',header=T) ggplot(d, aes(x = Day, y = Length)) + geom_bar(aes(fill = Amount, order = Location), stat = "identity")...

Not able Zoom on D3 Group Bar Chart

javascript,d3.js,zoom,bar-chart
I have created a group bar chart, & try to apply zoom, but zoom is only happened for the first group & not for the complete group bar chart. Any help will be really appreciated. Thanks in advance. you can find working fiddle here: http://jsfiddle.net/fiddlefollower/qkHK6/893/ code details: var x0 =...

ggvis side-by-side barchart grouped by second variable

r,bar-chart,ggvis
I am in process of migrating from Excel to ggvis for data analysis. For a typical grouped bar chart with two variables, however I have difficulty to plot bar chart side-by-side instead of stacked. The following data has four steps A, B, C, D with "ratio" data from two features...

Averaging rows by multiple column variables in R

r,ggplot2,average,bar-chart,multiple-columns
I am trying to create a multiple bar chart of my data, depicting the mean of avgct for each region with error bars using ggplot2. Here is a sample of my data: gregion lregion avgct 1 e 1.146 1 e 0.947 2 e 0.908 3 e 1.167 1 t 1.225...

R-Project Barplot Colors

r,colors,bar-chart
I am new to R, and I am trying to create a simple barplot. I have been able to create a barplot with the correct values, but only a single color for all bars. If I change the code slightly ( using table() instead of as.table() ), I get the...

Include values to the barplot and pie charts in R

r,statistics,bar-chart,pie-chart

D3: Is there a name for this type of chart and code example?

d3.js,bar-chart
I've seen this kind of bar chart in a couple of places. This is from LinkedIn. The page is rather complicated. When you click on a bar, it recalculates and reorders the bars in the other columns. Here, San Fran is clicked. Is there an example of something like this...

MATLAB : bar graph_ modify parameters on axis

matlab,bar-chart
I have a bar graph with 2 different data (each with a different color as you can see on the picture). I would like to move the x-axis so it crosses at y=-100 (for example). So if a data = -40, I would like to have a bar from -100...

R: Barplot, add value directly next to bar and a description in a separate column [closed]

r,bar-chart
How can I achieve somethign like this in R:

Greek symbols in labels for bar chart in MATLAB

matlab,latex,bar-chart,matlab-figure
I would like to use greek symbols in the ylabels for my barh() chart. I tried the following but it didn't really work: tplot = barh(mdata, 'BarWidth', 0.3); set(gca,'xgrid','on') lbl = {'$$\hat{\sigma}_1$$', '$$\hat{\sigma}_2$$', '$$\hat{\sigma}_3$$'}; box off set(gca,'yticklabel',lbl) h=findobj(gca,'type','text'); set(h,'Interpreter','latex') I also tried: set(gca,'TicklLabelInterpreter', 'tex') When I do get(gca), the property...

Put one line chart and bar chart in one plot in R (Not ggplot)?

r,plot,ggplot2,data.frame,bar-chart
how to Combine a bar chart and line in single plot in R (from different data sources)? Say I have two data sources as: barData<-c(0.1,0.2,0.3,0.4) #In percentage lineData<-c(100,22,534,52,900) Note that they may not be in the same scale. Can I plot both barData and LineData in one plot and make...

Grouped barplot in ggplot2 in R

r,ggplot2,bar-chart
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...

Is there a way to have a barplot and a stacked barplot on the same graph using barplot or ggplot?

r,ggplot2,bar-chart,rstudio
I have two pieces of data that I want to overlay onto the same plot. I've looked at several ggplot articles and I don't think it's possible within ggplot. So I have been using barplot. I have 5 tiers and I'm plotting total dollars by tier as a solid bar....

How to make the placement of asterisks in a barplot easier?

r,bar-chart
I would like to place asterisks in my grouped barplot (R base) to indicate where the paired comparisons differ significantly. I know how to place these stars using the points command. However, from the posts that I read sofar it seems that one needs to find the right coordinates manually...

Stacking charts in JavaFX

javafx,javafx-8,bar-chart,linechart
I'm using a BarChart and a LineChart in JavaFX. When I make the two charts the same size and put them put at the same place they overlap eachother perfectly. How would I make the LineChart appear to e on top of the BarChart. For the moment I've been setting...

controlling time-scale & binwidth on x-axis in ggplot2

r,datetime,ggplot2,bar-chart
Here is a dput sample of the data I am working with: structure(list(time = structure(c(1426552275, 1426552184, 1426552085, 1426551044, 1426550965, 1426550791, 1426550346, 1426549180, 1426549031, 1426548975), class = c("POSIXct", "POSIXt"), tzone = "EST"), location = c("South Africa,New York City", "Utah", "United States Of Africa", "New York", "ATLANTA", "Atlanta, GA", "New York City!",...

R order a table for barplot by predefined settings

r,graph,order,bar-chart

Barplot sum of observations in two groups in R

r,bar-chart
I have data of the form: mydata <- data.frame(test = 1:20, group = sample(c("A", "B"), 20, rep=TRUE), var1 = sample(c("yes", "no", "NA"), 20, rep=TRUE), var2 = sample(c("yes", "no", "NA"), 20, rep=TRUE), var3 = sample(c("yes", "no", "NA"), 20, rep=TRUE), var4 = sample(c("yes", "no", "NA"), 20, rep=TRUE), var5 = sample(c("yes", "no", "NA"),...

Bar graph using php and mysql

javascript,php,mysql,arrays,bar-chart
Requirement Bar chart from MySql data , i have working code for static bar chart the code as follows --> <script> var data = [ [0, 11], //London, UK [1, 15], //New York, USA [2, 25], //New Delhi, India [3, 24], //Taipei, Taiwan [4, 13], //Beijing, China [5, 18] //Sydney,...

normalized bar heights in ggplot

r,ggplot2,bar-chart
I am trying to compare two sets of count data with ggplot. The datasets are of different lengths and I am having trouble figuring out how to normalize the bar heights to the number of rows in each dataset. Please see the code examples below: Example dataset set.seed(47) BG.restricted.hs =...

Set custom colours for tooltip squares Chart.js

jquery,charts,html5-canvas,bar-chart,chartjs
When using Chart.js is it possible to change the colour of the squares within the tooltip that is used to respresent each bar? I've noticed that when you change the pointColor value it affects the colour of the squares but can you somehow use a different colour other than whats...

Putting space between bars using bar function

matlab,plot,bar-chart
I am try to plot 16 bars, 8 of these belong to one group. I want to give this group the red color, the other 8 belong to another group which is given the blue color. I would like to arrange the bar in pairs, each pair containing one from...

Set a minimum height on bars in D3 graph

javascript,angularjs,d3.js,bar-chart
I think this should be fairly simple, but I'm new to D3 and don't know where to start. I'd like to set a minumum height to the bars in my bargraph so that even bars with a value of 0 are still visible. I'd also like this to be accurately...

Plot bars starting from x axis not equal to 0 and extend to both sides

r,plot,bar-chart
Suppose my data values are x <- c(30,50,70,120,150) I want them in horizontal format (horiz=T). Now My y axis position is in x=100 and I want bars to start from x=100, not from 0, and it should extend to left and right sides What to do? x=c(30,50,70,120,150) barplot(x,horiz=T) axis(2,pos=100) but...

geom_bar from min to max data value

r,plot,ggplot2,bar-chart,geom-bar
I am not sure if geom_bar is able (probably I'm not) to create the plot I need with geom_bar. I want a bar plot but not starting from 0, I have a minimum and maximum value that are to be the start and end points of each bar. Desired output...

How to adjust grid lines in R's barplot?

r,grid,bar-chart
I am using grid() inside of barplot() (using the panel.first argument) to draw the grid lines. However, the grid lines do not match the ticks of y-axis. Can anyone tell me how to solve this problem? My code is like below, thanks. WRE <- c(1423, 41721) bp <- barplot(WRE, xaxt...

R: Stacked bar chart from two column data

r,bar-chart,stacked-chart
I'm trying to create a stacked bar chart from data held in a data frame that has two columns. An example of the data format is below: Date Speed 01/01/2013 56 01/01/2013 45 01/01/2013 34 02/01/2013 23 02/01/2013 12 02/01/2013 1 03/01/2013 48 For each day I need to count...

How can I create hierarchical bar chart in d3.js

javascript,d3.js,bar-chart,hierarchy,hierarchical
I wanted to use the Sortable Bar Chart of Mike Bostock without it's transition property and sort the bars according to their lenght but I couldn't. I want the bars just like this. without interactivity. <!DOCTYPE html> <meta charset="utf-8"> <body> <style> body { font: 10px sans-serif; } .bar rect {...

How to add three legends of a bar graph in matlab?

matlab,plot,bar-chart,legend,precision-recall
i have a bar graph which calculates precession and recall for three different methods and represents them in three different colors, code i used is as follows x=[0.4,0.31,0.21] y=[0.45,0.38,0.27] bar(x,y,0.1) h = bar(x,diag(y),0.1,'stacked'); xlabel('precession') ylabel('recall') i want to add a legend that should show maroon color is for indiscernible relation,...

Android - BarChart, Bargraph

android,bar-chart
I want to implement a feedback/rating chart in my android app.(it is like when you open the google play and check an app's feedback there is a colourful graph from users who had voted it) Can anyone help me how to start that? I appreciate any help you can provide.

Core Plot horizontal bar chart on negative y-axis

core-plot,bar-chart
I have a requirement to draw Core Plot horizontal bar chart with everything on the negative y-axis. I.e. the first index should appear at -1, like below: I have figured out how to draw horizontal Bar Chart. But figuring out how to draw them in an "inverted" manner (to let...

How to remove bars for those bars with zero value in Chartjs bar chart?

html5,html5-canvas,bar-chart,chartjs
Even if the bars have value of zero in bar chart created using chartjs, they still show a visible bar. This is misleading for my purpose and I would like to have it removed and show nothing there (meaning that, I still want to show labels with zero value but...

barplot column for

r,bar-chart,na
I would like to have a column in my barplot for missing data. adult <- read.csv( "http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data", header = FALSE, na.strings = "?", strip.white = TRUE ) colnames(adult) <- c("age", "workClass", "fnlwgt", "education", "educationNum", "maritalStatus", "occupation", "relationship", "race", "sex", "capitalGain", "capitalLoss", "hoursPerWeek", "nativeCountry", "prediction") barplot(table(adult\$workClass), main="Job Distribution", xlab="Job", ylab="Count",las=2) I...

Google Chart with Category Picker and SQL Database

c#,asp.net,bar-chart
I want to draw a google chart with data comes from a stored procedure in MS SQL and also use a category picker. So far my code only show a blank page and i don't know where is the mistake. The stored procedure return a table which looks like this...

How to add Aggregate (Sum) To Kendo UI Stacked Bar Chart

javascript,kendo-ui,bar-chart
I have a simple bar chart with basic data. The tooltip shows the specific value it is representing which is good. I want to, just below it, show the Total for that entire bar/stack. So if the top bar had 10, 20, 50 for its corresponding values, the total for...

how to group two barchat from mpandroidchart lib

android,bar-chart
I want display in groups of two barcharts the following barcharts: Any feedback will be appreciate. Here is code: public class BarChartActivityMultiDataset extends DemoBase implements OnSeekBarChangeListener { private BarChart mChart; private SeekBar mSeekBarX, mSeekBarY; private TextView tvX, tvY; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);...