# Increase size of geom_point for one factor level

Say I like to increase the size of only those data points where the factor variable cyl == 6. How can I do that? ggplot(mtcars, aes(x = qsec , y = mpg, col = as.factor(cyl ))) + geom_point(size= 2) I do not want to use the size option here: ggplot(mtcars, aes(x = qsec , y… Read More Increase size of geom_point for one factor level

# Remove the trend line caused by geom_smooth in R

I am trying to remove the trend line which is created while using geom_smooth. The expectation is to just get the confidence interval without the trend line. I am not sure how to go about with it, can someone help me out? The data frame I am working with is: structure(list(Date = structure(c(19389, 19417, 19448,… Read More Remove the trend line caused by geom_smooth in R

# Wrong order of y values in ggplot barplot

I’ve got 3 groups, each one showing the number of sales for two types of clients (historical and tele-rehab). I’m trying to plot the sales in the order I defined them: In the BI gain group: First sale is historical, black colour = 30 Second sale is tele-rehab. white colour = 20 In the BI… Read More Wrong order of y values in ggplot barplot

# How to stop geom_point from interfering with geom_bar?

I have a complicated (for me atleast) ggplot. There are 3 things I just can’t figure out how to change. 1) How to I change the color of the geom_point from pink to my defined color code? 2) How do I remove the word colour from the legend? 3) How to I make it so… Read More How to stop geom_point from interfering with geom_bar?

# Can't change the color of Bar chart in R

barchart <- ggplot(data=penguins)+ geom_bar(mapping=aes(species)) barchart + scale_fill_manual(values = c("Adelie"="purple","Chinstrap"="orange", "Gentoo"="green")) Hi, I am new to R, and programming in general, I am trying to designate a specific color to my bar chart, so I wrote. But the bars are still grey in the plot, would like to know why and thanks for everyone helped. >Solution… Read More Can't change the color of Bar chart in R

# Add an extra legend to facet in ggplot

I want to add few individual data points to selected facet and have a legend for them. library(ggplot2) ggplot(data=mpg, aes(displ, hwy)) + geom_bin2d()+ facet_wrap(~class) + geom_point(data = data.frame(displ = c(5,3,6,4), hwy = c(25,30,35,27), type="XX", class = "pickup"), colour="blue") With this I get the legend for counts but how can I add a custom legend for… Read More Add an extra legend to facet in ggplot

# How to change the order in which a matrix is plotted in R?

I want to plot an image in matrix form. The image is ordered in such a way that the values need to be plotted from top left to bottom right. However, when I try to plot it (in either base R, or using ggplot), the values are not plotted on the locations where I expect… Read More How to change the order in which a matrix is plotted in R?

# How to change the order in which a matrix is plotted in R?

I want to plot an image in matrix form. The image is ordered in such a way that the values need to be plotted from top left to bottom right. However, when I try to plot it (in either base R, or using ggplot), the values are not plotted on the locations where I expect… Read More How to change the order in which a matrix is plotted in R?

# Partial Fill Stacked Barplot in ggplot2

I would like to make a barplot with different categories of appointments as different colors, and appointment for each color, partially filled based on whether it was cancelled or not. MWE: library(tidyverse) df <- tribble( ~ apt, ~ count, ~ attended, "Consult", 5, 3, "Follow Up", 3, 2, "Procedure", 6, 6 ) %>% mutate(apt =… Read More Partial Fill Stacked Barplot in ggplot2

# How can I center geom_label_repel labels so that they are in the middle of each bar?

I’m using geom_label_repel to place percentages in a faceted horizontal bar chart, which mostly works great, except that I can’t seem to find a way to shift the labels to the middle (or as close as possible) of each bar. Instead, they are justified right, which visually is a bit confusing as some bars are… Read More How can I center geom_label_repel labels so that they are in the middle of each bar?