Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Option for size and color represent two column value of a circle #9

Closed
kvshams opened this issue May 15, 2023 · 3 comments · Fixed by #25
Closed

Feature request: Option for size and color represent two column value of a circle #9

kvshams opened this issue May 15, 2023 · 3 comments · Fixed by #25
Labels
enhancement New feature or request

Comments

@kvshams
Copy link

kvshams commented May 15, 2023

Thanks for the great plotting package!
Are there any option for adding color and size of the circle to plot a dependent variables.

To add a similar column to the plot

library(ggplot2)

data <- data.frame(
  variable = c("Var1", "Var2", "Var3", "Var4"),
  beta = c(0.5, -0.3, 0.7, -0.1),
  pvalue = c(0.02, 0.05, 0.01, 0.2)
)

ggplot(data, aes(x = 1, y = variable)) +
  geom_point(aes(size = pvalue, fill = beta), shape = 21, color = "black") +
  scale_size_continuous(range = c(2, 10)) +
  scale_fill_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0) +
  guides(fill = FALSE) +
  theme_minimal() +
  theme(axis.text.y = element_blank(), axis.ticks.y = element_blank(),
        axis.title.y = element_blank(), panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(), axis.line = element_blank())
@kvshams kvshams changed the title Feature request: Option for size and color represent two column value Feature request: Option for size and color represent two column value of a circle May 15, 2023
@rcannood
Copy link
Collaborator

Hi @kvshams ! I will put this on the roadmap. However, I think the resulting changes might take a while to implement.

@rcannood
Copy link
Collaborator

rcannood commented Jul 7, 2023

I'm tinkering with a solution for this issue. As mentioned in funkyheatmap/funkyheatmapjs#6, I propose making the following changes to the column_info format:

I think that makes total sense. I think this is related to #9, in a sense.

I propose changing the column_info as follows:

  • size: a column in data which defines the size of the geom
  • color: a column in data which defines the colour of the geom
  • label: a column in data which plots a label on top of the geom (in which case we wouldn't need the overlay=TRUE anymore). this label should fit inside of the space allocated for that data point (I'm considering using ggfittext for this.
  • hover_text or simply hover: render this text when hovering over an element (JS only)

For backwards compatibility, specifying the id automatically uses it to set the size and color (and maybe hover_text in JS?).

@rcannood
Copy link
Collaborator

rcannood commented Jul 7, 2023

Alternatively, we could use id_size, id_color, id_label and id_hover to ensure these column names don't clash with the color parameter that is already allowed for the text geom and to show that there is a clear connection between the id column and the other columns. Using geom_ as a prefix is also fine by me.

This was referenced Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants