0

I would like to have the text and the geom_area fill in a specific colour. The colour code is : #795fc6
I tried but it is not working and the fill=0.1 isn´t the right colour at all.

My dataset consists of 26 variables of 4662 observations. For this plot I just need two variables. anaylysis_date (date format YYYY-MM-DD ) the y-axis is the sum of all observations occured at each day of the analysis period.

enter image description here

This is a reproducible example of the analysis date column :

df = c("2017-11-12", "2018-03-28", "2018-06-30", "2018-06-22", "2018-09-24" ,"2018-11-21")

This is my plot at the moment:

ggplot(data = DatasetApp, aes(x=analysis_date, fill=0.1)) +
  geom_area(stat="bin",axis.text.x=col=c("#795fc6")) +
  labs(x="Date",y="Number of Observations", title = "Number of observations pre and post GDPR", col="#795fc6")+
  geom_vline(xintercept = as.numeric(DatasetApp$analysis_date[GDPR_date]), color=c("#5034c4"))+
  theme_minimal()
tamtam
  • 3,541
  • 1
  • 7
  • 21
Paul
  • 23
  • 5
  • 1
    Welcome to SO! To help us to help you could you please make your issue reproducible by sharing a sample of your **data**? See [how to make a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Simply type `dput(NAME_OF_DATASET)` into the console and copy & paste the output starting with `structure(....` into your post. If your dataset has a lot of observations you could do e.g.`dput(head(NAME_OF_DATASET, 20))` for the first twenty rows of data. – stefan Jun 03 '21 at 12:42

1 Answers1

0

So in short you want the plot to be totaly purple.
The area filling can be changed with the fill argument outside of the aes argument. Text colors are set inside the theme function with the arguments text (changes color of title and axis titles) and axis.text (changes axis labels).

Data

df <- data.frame(date = as.Date(c("2017-11-12", "2018-03-28",
                                  "2018-06-30", "2018-06-22", 
                                  "2018-09-24" ,"2018-11-21"), 
                                format = "%Y-%m-%d"))

Code

ggplot(data = df, aes(x=date)) +
  geom_area(stat="bin", fill = "#795fc6") +
  labs(x="Date",
       y="Number of Observations", 
       title = "Number of observations pre and post GDPR")+
  geom_vline(xintercept = df[3,1], 
             color="#5034c4")+
  theme_minimal() +
  theme(text = element_text(color = "#795fc6"),
        axis.text = element_text(color = "#795fc6"))

Plot
enter image description here

tamtam
  • 3,541
  • 1
  • 7
  • 21