Questions tagged [stacked-chart]

For questions about stacked charts, i.e. charts where multiple data series are superimposed.

Stacked are charts in which you collect multiple data series and display their cumulative values. These can be stacked histograms, stacked areas, or a number of other arrangements.

Stacked areas Stacked areas adding up to 100% 3d example Stacked area chart

Typical questions involve how to get this sort of layout from various plotting engines and how to affect details like legends, orientation, color palette, grouping, etc.

674 questions
56
votes
2 answers

Reverse stacked bar order

I'm creating a stacked bar chart using ggplot like this: plot_df <- df[!is.na(df$levels), ] ggplot(plot_df, aes(group)) + geom_bar(aes(fill = levels), position = "fill") Which gives me something like this: How do I reverse the order the stacked…
Simon
  • 9,762
  • 15
  • 62
  • 119
35
votes
1 answer

Position geom_text in the middle of each bar segment in a geom_col stacked barchart

I would like to position the corresponding value labels in a geom_col stacked barchart in the middle of each bar segment. However, my naive attempt fails. library(ggplot2) # Version: ggplot2 2.2 dta <- data.frame(group = c("A","A","A", …
chamaoskurumi
  • 2,271
  • 2
  • 23
  • 30
15
votes
1 answer

count plot with stacked bars per hue

I am looking for an efficient way of drawing a count plot with stacked bars according to "hue". Standard hue behavior is to split a count into parallel bars according to the value of a second column, what I am looking for is an efficient way to…
Marcello
  • 327
  • 1
  • 2
  • 11
15
votes
3 answers

different colors for each bar in stacked bar graph - base graphics

I want to plot a stacked bar graph like the one attached, but I want the colors to vary between the categories aa, bb and cc. Specifically, I want the grey blocks in bb to be red and the grey blocks in cc to be green. The following code serves as a…
Martin
  • 163
  • 1
  • 5
15
votes
1 answer

Vertically stacked Google Bar Charts

I'm trying to produce a vertically stacked bar chart using the Google Charts API and I thought I had found the solution when I found the option: isStacked: true However, This seems to add the stacking horizontally (see link below) and I cant seem…
MarkP
  • 2,546
  • 5
  • 31
  • 48
13
votes
1 answer

Is it possible to put space between stacks in ggplot2 stacked bar?

I took this example from here: DF <- read.table(text="Rank F1 F2 F3 1 500 250 50 2 400 100 30 3 300 155 100 4 200 90 10", header=TRUE) library(reshape2) DF1 <- melt(DF,…
Soheil
  • 954
  • 7
  • 20
12
votes
2 answers

ggplot2: Changing the order of stacks on a bar graph

I'm trying to make a stacked bar graph with a facet_wrap, but I want the order of my stacked variables ("developed") to be flipped. I've reordered the factors, and tried "order=descend()," as well as "scale_fill_manual" and nothing seems to…
Natalie K
  • 121
  • 1
  • 6
10
votes
1 answer

Stacked bar charts using python matplotlib for positive and negative values

I am trying to plot a stacked bar chart with python Matplotlib and I have positive and negative values that I want to draw. I have had a look at other posts talking about how to plot stacked bar charts with positive and negative values, but none of…
Juwairia
  • 101
  • 1
  • 1
  • 5
9
votes
2 answers

Click event on stacked bar chart - ChartJs

I am trying to implement click event on Stacked Bar chart. The data looks like below: var chartData = { type: 'horizontalBar', data: { labels: ['A0224', 'A3681', 'A3984', 'A4101', 'A4150', 'B0682', 'Others'], datasets: [ …
9
votes
3 answers

Google Chart, how to move annotation on top of columns

I'm using Google Chart's stacked column chart, what i wanna achieve is to display the total on top of each column and i'm using annotation for this. As you look at the image, somehow only the annotation on the 5th column (1,307.20) is working as…
nqtien310
  • 227
  • 2
  • 3
  • 11
8
votes
2 answers

Stacked Bar in ng2-charts

I have gone through the documents of ng2-charts but I couldn't find anything like Stacked Bar. Is there is any other way to achieve Stacked Bar chart in ng2-charts? Please help me out
Felix Christo
  • 257
  • 6
  • 19
8
votes
1 answer

Label Areas in Python Matplotlib stackplot

I would like to generate labels inside the areas of a matplotlib stackplot. I would settle for labeling a line used to bound the area. Consider the example: import numpy as np from matplotlib import pyplot as plt fnx = lambda : np.random.randint(5,…
Docuemada
  • 1,703
  • 2
  • 25
  • 44
6
votes
2 answers

Matplotlib bar chart - overlay bars similar to stacked

I want to create a matplotlib bar plot that has the look of a stacked plot without being additive from a multi-index pandas dataframe. The below code gives the basic behaviour %matplotlib notebook import numpy as np import matplotlib.pyplot as…
Esme_
  • 1,360
  • 3
  • 18
  • 30
6
votes
1 answer

D3.js Stacked Bar Chart, from vertical to horizontal

I like to make this vertical Bar Chart (http://bl.ocks.org/mbostock/3886208) to a horizontal Bar Chart. Thanks for your help! Code examples would be nice.
Daniel Z
  • 63
  • 1
  • 5
5
votes
0 answers

Excel stacked bar chart not plotted correctly

I am using Axlsx gem for generating the excel charts on ruby on rails. My requirement is to generate a stacked bar chart but it is generating in a staircase format refer the image here. To generate the chart I have used the following…
Aditya Tiwari
  • 204
  • 4
  • 17
1
2 3
44 45