-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Adjusting scatter edge colors when using scatter and line plot at the same time #6164
Comments
I don't see a problem with this approach just for your info there is a way to have a new color scale ( if you want to map something different for the line layer versus the point layer library(tidyverse)
set.seed(165465)
data <- tibble(lat = c(38:46),
tot = 20+runif(9),
week = 10+runif(9,min = 0,max = 5))
data_tidy <- data |>
pivot_longer(cols = !lat,names_to = 'class',values_to = 'value')
ggplot(data = data_tidy, aes(x = value, y = lat))+
geom_line(aes(color = class),orientation = 'y',linewidth = 6)+
geom_point(aes(fill = class),color = "transparent", size = 9, shape =21)+
geom_point(aes(color = class),fill = "transparent", size = 8, shape =21)+
scale_color_manual(values = c('red','blue'))+
scale_fill_manual(values = c('yellow','green')) Created on 2024-10-28 with reprex v2.1.1 |
@smouksassi Thank you for the information, this is indeed a solution to my problem! https://eliocamp.github.io/ggnewscale/ |
Yes, I'd also say that ggnewscale is the way to go for this type of problem. As this isn't a bug report or feature request, I'm going to close this issue. I'll also leave a kind reminder that stackoverflow and the posit community are better venues for getting regular usage questions answered. |
I'm sorry. |
I'm having some problems when I'm approximating the reproduction of the image below.
scale_color_...
This command adjusts both the color of the line and the color of the edge of the point (shape = 21).To achieve a similar effect, I made some combinations of type points. The code is as follows:
But I'm not sure there is a simpler and more direct way to achieve this effect.
I would like to achieve that the color of points (fill color) and lines is determined by a certain type of attribute, but the color of the edges of the points depends on this attribute but is at the same time different from the fill.
The text was updated successfully, but these errors were encountered: