Coder Social home page Coder Social logo

"Removing" the violin plot from `ggbetweenstats` does not really remove it, but rather adds a thin line on the plot. about ggstatsplot HOT 5 CLOSED

luk-brue avatar luk-brue commented on May 27, 2024
"Removing" the violin plot from `ggbetweenstats` does not really remove it, but rather adds a thin line on the plot.

from ggstatsplot.

Comments (5)

luk-brue avatar luk-brue commented on May 27, 2024

Maybe the accepted answer on this SO question is an option to implement the "removing geoms" functionality. It really removes geoms from the grid object instead of changing their attributes to hide them.
https://stackoverflow.com/questions/13407236/remove-a-layer-from-a-ggplot2-chart

Here is how it looks on the reprex from above: It solves the problem.

# Function definition from SO:
remove_geom <- function(ggplot2_object, geom_type) {
  # Delete layers that match the requested type.
  layers <- lapply(ggplot2_object$layers, function(x) {
    if (class(x$geom)[1] == geom_type) {
      NULL
    } else {
      x
    }
  })
  # Delete the unwanted layers.
  layers <- layers[!sapply(layers, is.null)]
  ggplot2_object$layers <- layers
  ggplot2_object
}

p <- ggstatsplot::ggbetweenstats(outlier_data, group, response)
remove_geom(p, "GeomViolin")

grafik

from ggstatsplot.

IndrajeetPatil avatar IndrajeetPatil commented on May 27, 2024

It's the same issue as #895

You just need to pass: violin.args = list(width = 0, linewidth = 0) to solve the problem.

from ggstatsplot.

luk-brue avatar luk-brue commented on May 27, 2024

I tested the linewidth = 0 addition, but for me, it does not fix the problem at all:

ggstatsplot::ggbetweenstats(outlier_data, group, response,
                            violin.args = list(width = 0, linewidth = 0))

grafik

If you make it blue, you can clearly see that the line belongs to the violin plot.

ggstatsplot::ggbetweenstats(outlier_data, group, response,
                            violin.args = list(width = 0, 
                                               linewidth = 0,
                                               color = "blue"))

grafik

from ggstatsplot.

IndrajeetPatil avatar IndrajeetPatil commented on May 27, 2024

I've already documented this in #900. Just waiting to merge it.

from ggstatsplot.

luk-brue avatar luk-brue commented on May 27, 2024

Thanks, I have looked at it. I can only see that you documented the linewidth = 0 argument in your commit with the message "correct way to remove violin plot".

Please read my comment above where I say that this linewidth = 0 argument does not work for me.
Do you have any idea why? Can you reproduce this behaviour?

from ggstatsplot.

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.