ggplot2

Combining linetype and color in ggplot2 legend

本小妞迷上赌 提交于 2021-02-08 17:24:55
问题 I have a dataframe like this : > head(df_graph) treatment year mean se 1: AC 2005 0.3626147 0.03005057 2: AC 2006 0.3925465 0.02370335 3: AC 2007 0.3217444 0.02279881 4: AC 2008 0.3895656 0.05985077 5: AC 2009 0.3820191 0.01481586 6: AC 2010 0.3732695 0.03544626 ... And a (long) ggplot script : df_graph %>% # way to make 2 lines becoming 4 in a smooth way filter(treatment %in% c("Ambient", "Elevated")) %>% mutate(treatment = ifelse(treatment == "Ambient", "AA", "EE")) %>% bind_rows(df_graph)

R: suitable plot to display data with skewed counts

风格不统一 提交于 2021-02-08 15:01:26
问题 I have data like: Name Count Object1 110 Object2 111 Object3 95 Object4 40 ... Object2000 1 So only the first 3 objects have high counts, the rest 1996 objects have fewer than 40, with the majority less than 10. I am plotting this data with ggplot bar like: ggplot(data=object_count, mapping = aes(x=object, y=count)) + geom_bar(stat="identity") + theme(axis.title.x=element_blank(), axis.text.x=element_blank(), axis.ticks.x=element_blank()) My plot is as below. As you can see, because there are

geom_smooth() - and scaling the y axis, losing data from smoothing

杀马特。学长 韩版系。学妹 提交于 2021-02-08 12:34:05
问题 Apologies that this example isn't that great but it does highlight the point. mtcars$tran <- factor(mtcars$am, labels=c("Man","Aut")) ggplot(mtcars, aes(x=hp, y= mpg, group=tran)) + geom_smooth(aes(colour=tran)) ggplot(mtcars, aes(x=hp, y= mpg, group=tran)) + geom_point(aes(colour=tran)) ggplot(mtcars, aes(x=hp, y= mpg, group=tran)) + geom_point(aes(colour=tran)) + geom_smooth(aes(colour=tran)) ggplot(mtcars, aes(x=hp, y= mpg, group=tran)) + geom_smooth(aes(colour=tran)) + scale_y_continuous

r - using ggplot to show a dot as the value [closed]

孤街醉人 提交于 2021-02-08 12:15:33
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Improve this question I have a data frame like this: CWSR = c(0.2, 0.1, 0.5, 0.6, 0.4, 0.8, 0.9, 0.7, 0.1, 0.2) BPA = c(1,5,9,8,4,3,2,1,4,3) df = data.frame(CWSR, BPA) CWSR BPA 1 0.2 1 2 0.1 1 3 0.5 9 4 0.1 2 5 0.4 4 6 0.1 2 7 0.9 2 8 0.1 3 9 0.1 2 10 0.2 3 I have generated the below histogram but

r - using ggplot to show a dot as the value [closed]

人盡茶涼 提交于 2021-02-08 12:14:29
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Improve this question I have a data frame like this: CWSR = c(0.2, 0.1, 0.5, 0.6, 0.4, 0.8, 0.9, 0.7, 0.1, 0.2) BPA = c(1,5,9,8,4,3,2,1,4,3) df = data.frame(CWSR, BPA) CWSR BPA 1 0.2 1 2 0.1 1 3 0.5 9 4 0.1 2 5 0.4 4 6 0.1 2 7 0.9 2 8 0.1 3 9 0.1 2 10 0.2 3 I have generated the below histogram but

How to fit a bell-shaped curve on 2 dimensional scatter data?

匆匆过客 提交于 2021-02-08 12:13:45
问题 I have x-y scatter data, which exhibit bell-shaped (i.e. normal distribution shaped) behaviour over the course of a year. These are primary production data from high latitudes (more in detail here, the article is paywalled, but I hope that the figures are visible). Question How do I fit a normal distribution shaped curve on scatter data in ggplot2? Example data x <- structure(list(yday = c(238, 238, 238, 242, 242, 250, 250, 253, 254, 169, 199, 208, 230, 21, 37, 88, 94, 102, 125, 125, 95, 98,

ggplot with two y-axis in R?

跟風遠走 提交于 2021-02-08 12:11:40
问题 I have asked this question earlier but someone close it indicating that it has answer. I am pretty confuse how i can get the two variables plotted on two Y-axis . I want to plot Level on the left y-axis and Flow on the right y-axis (ie., secondary axis). Here is my data and i would appreciate a response. library(tidyverse) library(lubridate) set.seed(1500) FakeData <- data.frame(Date = seq(as.Date("2020-01-01"), to = as.Date("2020-01-31"), by = "days"), Level = runif(31, 0, 30), Flow = runif

ggplot with two y-axis in R?

这一生的挚爱 提交于 2021-02-08 12:11:13
问题 I have asked this question earlier but someone close it indicating that it has answer. I am pretty confuse how i can get the two variables plotted on two Y-axis . I want to plot Level on the left y-axis and Flow on the right y-axis (ie., secondary axis). Here is my data and i would appreciate a response. library(tidyverse) library(lubridate) set.seed(1500) FakeData <- data.frame(Date = seq(as.Date("2020-01-01"), to = as.Date("2020-01-31"), by = "days"), Level = runif(31, 0, 30), Flow = runif

How to add annotation over line plot to mark percent change in y-values between discrete x-values

房东的猫 提交于 2021-02-08 10:38:28
问题 I want to visualize the results of a linear model where dependent variable values change as a function of discrete x-values. Since my x-values represent consecutive days, I want to annotate the change from day to day, in percents. How can I do this in a line plot? My Data I want to measure people's mood. Every day I collect responses from 1000 different people on how they feel. I therefore get a daily average for mood, and I want to see how it changes from one day to another. library

How to add annotation over line plot to mark percent change in y-values between discrete x-values

狂风中的少年 提交于 2021-02-08 10:36:14
问题 I want to visualize the results of a linear model where dependent variable values change as a function of discrete x-values. Since my x-values represent consecutive days, I want to annotate the change from day to day, in percents. How can I do this in a line plot? My Data I want to measure people's mood. Every day I collect responses from 1000 different people on how they feel. I therefore get a daily average for mood, and I want to see how it changes from one day to another. library