Category "ggplot2"

Heatmaps with eye-tracking data (weighted 2D-density)

I am trying to create a fixation maps where the weight of each fixation on the 2d density map is determined by its duration. As I understood, the stat_density2d

In `geomtextpath/geom_textline`, is it ok to use `y/x` value to change label position

In geomtextpath/geom_textline, we can change the label position using parameter vjust/hjust, is it ok to use y/x value directly. Thanks! library(ggplot2) librar

Ordering bar chart by value in R using ggplot2 [duplicate]

I am having trouble creating a bar chart utilizing ggplot2 that is sorted by value. I understand that I can order the data frame by the value

Reordering boxplot (ggplot) with scale_x_discrete(limits=(...) results in Warning message: Removed 103 rows containing missing values (stat_boxplot)

Probably a user error but I can't find it for the life of me. Trying to rearrange the order of factors in a boxplot I am making using ggplot using the, "scale_x

How to automatically make an axis with a gradation from 1 to max(n) when using facet_wrap ggplot2

I have a data.frame(tt) with 3 columns: nazvReki - grouping variable (18 values); rang - axis X (443 entries from 1 to 70. It takes values from 1 to 70, but for

Plot with circlize

I work with library circlize and I made plot. Below you can see code library(circlize) random_values<-c(500:100) random_sample<-sample(random_values,15)

How to changes words in a charts title based on condition?

I would like the title of my plot to change based on if the supply is over or under the estimate. The estimate of the supply is in DF$Supply.. If it is positive

smartEDA - Assign unique color to target categories

I was exploring the capabilities of the smartEDA package and stuck with a challenge. The target column "US" has 2 categories - "Yes" and "No". The output (below

R - get value of one variable for maximum value of another variable INSIDE a ggplot call

I have some code like this: seq(0, 2*pi, length.out = 100) %>% cbind.data.frame(t = ., Y = sin(.)) %>% qplot(t, Y, data = ., geom = "line")+ geom_

data column not recognized in the ggplot geom_hline

I was wondering why variable mean_y is not recognized by my geom_hline(yintercept = unique(mean_y)) call? library(tidyverse) set.seed(20) n_groups <- 2 n_in

Stacked barchart with 3 variables

I have a survey data with respondents answering multiple questions. In one variable, respondents express their opinion about a party "1" = favorable and "0" = u

Plotly not displaying the labs caption from ggplot

I have this code for making a ggplot, which works fine (MRE with a built-in dataset): mydata <- airquality avg <- mean(mydata$Wind) stde <- sd(mydata$W

geom_segment not recognising factored x-axis

Aim: produce a bar plot representing a time series of measurements (variables) taken at 14 Sites (factors), including drawing horizontal lines to demonstrate be

what are these gray lines inside the bars of my ggplot bargraph?

I wanted to create a graph to show which continent has the highest co2 emissions total per capita over the years, so I coded this: barchart <- ggplot(data =

How to delete label above bar chart in R that's already in the legend?

this is my first post! Just wondering how to remove these titles above the charts: Here's the code for the diagram! I imagine I'll have to use something like:

fancy pie chart in R using ggplot2

I have a pie chart below, and I would like to leave extra white space between each pie and paste the value of each letter in each pie (A=25). how to get around

R: How to remove spikes/outliers on ggplot2

Given the following R script: library(glue) library(ggplot2) library(tidyverse) library(magrittr) library(stringi) library(dplyr) ir.data <- read.csv(file="

ggplot line legend disappears with alpha < 1

When trying to plot some data in ggplot2 using geom_line(), I noticed that the legend items become empty if I use alpha < 1. How can I fix this and why is th

Melt a frequency table in order to use ggplot2

I have a "frequency table" similar to this one # Create a matrix df<- matrix(sample(0:10,35,replace=T),nrow=5, ncol=7) # Rename columns and rows colnames

How can I reorder facet wrap by the values of the first column?

The following code is from Stefan, who answered a related question library(ggplot2) library(dplyr) library(tidyr) library(tidytext) mtcars2 <- as_tibble(mtc