Coder Social home page Coder Social logo

Comments (2)

davidgohel avatar davidgohel commented on August 23, 2024

You need to add a group aesthetic

library(ggiraph)
library(ggplot2)
data <- structure(list(
  variable_label = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), levels = c("Bejing", "Brussels", "Budapest"), class = c("ordered", "factor")),
  category = structure(c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L, 3L), levels = c("Not at all", "A bit", "A lot"), class = "factor"),
  count = c(55L, 37L, 8L, 40L, 48L, 12L, 45L, 42L, 13L),
  proportion = c(0.55, 0.37, 0.08, 0.4, 0.48, 0.12, 0.45, 0.42, 0.13),
  data_label = c("0.55", "0.37", "0.08", "0.40", "0.48", "0.12", "0.45", "0.42", "0.13"),
  Tooltip = c("Not at all: 55", "A bit: 37", "A lot: 8", "Not at all: 40", "A bit: 48", "A lot: 12", "Not at all: 45", "A bit: 42", "A lot: 13")
), class = "data.frame", row.names = c(NA, -9L))

zz <- ggplot(data, aes(
  y = proportion,
  x = variable_label,
  fill = category,
  label = data_label,
  group = category
),
cumulative = TRUE
) +
  geom_col_interactive(
    mapping = aes(tooltip = Tooltip), # Messes up category order
    position = position_stack()
  ) +
  geom_text(position = ggplot2::position_stack(vjust = .5))
Capture d’écran 2023-07-30 à 15 51 44

from ggiraph.

sda030 avatar sda030 commented on August 23, 2024

Oh, whoops, this will be an easy workaround that I should have tried. Still found it a bit surprising as specifying group = is not necessary with regular ggplot2. But as long as it works I am happy! Thanks.

from ggiraph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.