mzkrc
mzkrc

Reputation: 419

How can customize the line width for groups in facetted graph in ggplot?

Although my question is related to line graph, it can be generalizable for other types of graphs and here it is.

Recently, I am trying to plot a facetted geom_line to show the annual change in particular groups given in my dataset. In other words, I do have more than 100 groups which I want to plot only 6 in a facetted graph with 6 different panels, one panel for each. However, pay attention that I do want to keep other groups in the plot, I do not want to remove them. I just want to highlight each particular group that I am interested in for each unique panel relevant to them and I want to customize the size in the panels for each groups so that they can be a bit thicker and therefore they can be seen more explicitly compared to others.

Therefore, my X axis is date (years), and my Y axis is Count. Here is the code I achieved that mission partially.

ggplot(df, aes(Year, Count, group = group, color = group)) +
  geom_line(alpha = 0.5, size = 0.1) +
  scale_color_manual(values = c("A" = "#DC8665", "B" = "#138086", 
                                "C" = "#534666",
                                "D" = "#CD7672", "E" = "#EEB462", "F" = "blue")) + 
  gghighlight(MİLLİYET %in% c("A", "B", "C",
                              "D", "E", "F"),
              use_direct_label = FALSE) +
  facet_wrap(~ group) +
  geom_point(data = d_filtered_point, aes(x =Year, y = Count, color = group), size = 0.3) +
  geom_text(aes(colour = group, label = group), vjust = -0.8, hjust = 1,
            data = d_filtered_point,
            size = 6) +
  theme_classic()

My code plots a facetted geom_line graph with 6 different panels, one for each group I am interested in by highlighting it while keeping other more than 100 groups and color them uniquely as shown in the below.

enter image description here

However, I also want to customize the size for these 6 groups as well to plot the particular group bolder for the particular panel, for instance make the particular group for the top left panel thicker. Although I searched a lot on the web, I could not find a solution. Therefore, I need your help, and I do appreciate your assistance in beforehand.

Upvotes: 0

Views: 137

Answers (0)

Related Questions