Skip to content

Commit

Permalink
Update spei.R
Browse files Browse the repository at this point in the history
Correct bug that prevented the SPEI plot to have different fill colors for positive and negative values in some systems.
  • Loading branch information
sbegueria committed Jul 12, 2023
1 parent 2c28170 commit 5772c17
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/spei.R
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,8 @@ plot.spei <- function(x, ...) {

# Plot it
g <- ggplot(kk, aes(.data[["time"]], .data[["value"]],
fill = "cat",
color = "cat"
fill = .data[["cat"]],
color = .data[["cat"]]
))
# reference period (if different than whole series)
if (!is.null(x$ref.period)) {
Expand All @@ -981,10 +981,10 @@ plot.spei <- function(x, ...) {
# add the bars with the SPEI values
g <- g +
geom_bar(stat = "identity") + # color='white' helps separate between values
# scale_fill_manual(values=c('blue','red')) + # classic SPEI look
# scale_color_manual(values=c('blue','red')) + # classic SPEI look
scale_fill_manual(values = c("cyan3", "tomato")) + # new look
scale_color_manual(values = c("cyan3", "tomato")) # new look
#scale_fill_manual(values=c('blue','red')) + # classic SPEI look
#scale_color_manual(values=c('blue','red')) # classic SPEI look
scale_fill_manual(values = c("cyan3", "tomato")) + # new look
scale_color_manual(values = c("cyan3", "tomato")) # new look
# add NAs
g <- g +
geom_point(aes(.data[["time"]], .data[["na"]]),
Expand Down

1 comment on commit 5772c17

@SafouaneMouelhi
Copy link

@SafouaneMouelhi SafouaneMouelhi commented on 5772c17 Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subject: Inquiry Regarding Probability Functions in SPEI Package

Dear Mr. Santiago Beguería sbegueria

I hope this message finds you well. I am currently working with the SPEI package and have been utilizing various probability distributions, including the log-logistic distribution.

First question :

I am particularly interested in extracting results related to the probability functions from the package. Specifically, I would like to obtain the empirical modeled F(x) values and the probability density functions values. My goal, if possible is to find this values stored in results lits for further analysis.

"The idea is to find the intermediate calculations related to the chosen probability distributions (such as the log-logistic distribution) included in the final list of results."

Could you please provide guidance on how I can achieve this? Any insights or examples would be greatly appreciated.

Second question:
What method did you use to address the issue of negative values?

Thank you for your time and assistance.

Best regards,
Safouane MOUELHI
PhD Water Sciences

Please sign in to comment.