I am going to provide my code below. there is my plot and at the sample plot i need to recreate. I don’t know how to add exactly same grey thick borders. Current plot Desired ggplot(data = melted_df, aes(sample = value, color = Distribution)) + stat_qq() + geom_qq_line() + facet_wrap(~Distribution, scales = "free") + xlab(‘Theoretical… Read More I need to add boarder to the strip in facet_wrap
What goes wrong in this barplot code? The variable names go over the bars and the bars are out of the x-axis scale on the left. df <- data.frame( x1 = 5.1, x2 = 5.5, x3 = 5.2 ) names(df) <- c(‘word word word word word’, ‘word word’, ‘word word word word’) df_long <- df… Read More Base R barplot: legends showing over the bars and bars are out of the x-axis scale
Suppose the data is: structure(list(Y = c(0.428559988737106, 0.429479986429214, 0.430400013923645, 0.431320011615753, 0.432240009307861, 0.433160006999969, 0.434080004692078, 0.435000002384186, 0.435920000076294, 0.436839997768402, 0.43775999546051, 0.438679993152618, 0.439599990844727, 0.440889984369278, 0.442179977893829, 0.443470001220703, 0.444759994745255, 0.446049988269806, 0.44734001159668, 0.448630005121231, 0.449919998645783, 0.451209992170334, 0.452499985694885, 0.453790009021759, 0.45508000254631, 0.456369996070862, 0.457660019397736, 0.458950012922287, 0.460240006446838, 0.46152999997139, 0.462819993495941, 0.464110016822815, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366, 0.465400010347366,… Read More How to plot three variables simultenously on a y-axis?
The following code produces two histograms. I’m wondering whether there’s any simple way to create a break in the dotted lines in the legend for these histograms. See the legend in the attached image – I want the dotted lines not to run into each other? #make low cost histogram PLOT1 <- LCset1 %>% ggplot(aes(x=donation,… Read More ggplot2 – how to add a break between dotted lines in legend?
I would appreciate some help with changing the axis titles given the format of my current ggplot. I’ve tried the usual arguments such as scale_x_discrete() and adding the associated labels, yet with no success. However, overall, my goal is to keep the current format of the stacked bar, yet change 1,2,3 on the x-axis to… Read More Customising X-axis on Stacked Bar Graph GGplot2
I am working with the R programming language. I have the following dataset: library(stringi) library(dplyr) library(tidyverse) set.seed(123) n <- 100 final <- data.frame(id = 1:n, var1 = rnorm(n), var2 = rnorm(n), var3 = rnorm(n)) final$new_id <- stri_rand_strings(n, 6, pattern = "[A-Za-z0-9]") The dataset looks something like this: id var1 var2 var3 new_id 1 1 -0.56047565… Read More R: Replacing Axis Labels With Another Variable
I have a data that look like this: cis_distance_freq4 # A tibble: 6 × 2 distance freq <dbl> <dbl> 1 0 NA 2 1000 4380 3 10000 4381 4 40000 4535 5 80000 4536 6 1000000 4558 hist(cis_distance$freq) I want to plot in such a way that x axis is distance and y axis is… Read More error while plotting hist plot for a dataframe in R
I want to save all my plots from my R environment with ggsave(). How can I save list of plots from environment in R and then use the list as input to ggsave() ? I got some plots with cars from here to illustrate: PlotA <- ggplot(mtcars, aes(x=hp, y=mpg, color=cyl, shape=cyl)) + geom_point(size=3) PlotB <-… Read More Save a list of plots from environment in R
I’m working with the dataset PatentsRD from the Ecdat library and came across a weird behavior with ggplot I have no explanaiton for. I plot two functions poisson distributions (once using the formula and once using dpois) to see wheter they are in fact identical: library(tidyverse) library(Ecdat) data(PatentsRD) plot <- ggplot(data = data.frame(x = c(0:100)),… Read More Weird behavior in ggplot's stat_function()
data(iris) barplot(iris$Sepal.Length, col = iris$Species) The default colors are black, red, and green. How can I change these colors to, say, yellow, blue, orange? For the 3 iris species, respectively? >Solution : Create a named vector of colors and match the species with the vector’s names. Use this to index the colors vector. data(iris) colrs… Read More How to customize bar plot color using base barplot in R