Skip to content

Commit

Permalink
added bug fix for scales pkg issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jongoetz committed Mar 27, 2024
1 parent 10da0bb commit db3efc7
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 43 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: fasstr
Title: Analyze, Summarize, and Visualize Daily Streamflow Data
Version: 0.5.1
Version: 0.5.2
Authors@R: c(person("Jon", "Goetz", email = "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4993-1119")),
person("Carl James", "Schwarz", email = "[email protected]", role = "aut"),
Expand Down Expand Up @@ -36,5 +36,5 @@ Suggests:
knitr,
rmarkdown,
testthat
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
VignetteBuilder: knitr
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
fasstr 0.5.2
=========================

Updated: 27 Mar 2024

### Bug fixes:

* added workaround for bug with scales::cut_short_scale() bug caused by scales 1.3.0.



fasstr 0.5.1
=========================

Expand Down
2 changes: 1 addition & 1 deletion R/compute_annual_trends.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ compute_annual_trends <- function(data,
ggplot2::theme_bw() +
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 12)) +
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale())) +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1))) +
ggplot2::theme(panel.border = ggplot2::element_rect(colour = "black", fill = NA, size = 1),
panel.grid = ggplot2::element_line(size = .2),
axis.title = ggplot2::element_text(size = 12),
Expand Down
4 changes: 2 additions & 2 deletions R/compute_frequency_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ compute_frequency_analysis <- function(data,
if(!use_max){ freqplot <- freqplot + ggplot2::theme(legend.justification = c(1, 1), legend.position = c(.98, .98))}
if(use_max){ freqplot <- freqplot + ggplot2::theme(legend.justification = c(1,0), legend.position = c(.98, 0.02))}
if(!use_log){ freqplot <- freqplot + ggplot2::scale_y_log10(breaks = scales::pretty_breaks(n = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}
if(use_log){ freqplot <- freqplot + ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}
# if(use_log & use_max ){freqplot <- freqplot + ggplot2::ylab(expression(lnDischarge~(m^3/s)))} # adjust the Y axis label
# if(use_log & !use_max){freqplot <- freqplot + ggplot2::ylab(expression(lnDischarge~(m^3/s)))}
# if(!use_log & use_max ){freqplot <- freqplot + ggplot2::ylab(expression(Discharge~(m^3/s)))}
Expand Down
12 changes: 6 additions & 6 deletions R/plot_annual_cumulative_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ plot_annual_cumulative_stats <- function(data,
ggplot2::geom_point(na.rm = TRUE)+
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 6)) +
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))+
ggplot2::ylab(expression(Volume~(m^3))) +
{if (use_yield) ggplot2::ylab("Yield (mm)")} +
ggplot2::xlab(ifelse(water_year_start ==1, "Year", "Water Year"))+
Expand Down Expand Up @@ -215,7 +215,7 @@ plot_annual_cumulative_stats <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(seasons2_data$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(seasons2_data$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))+
ggplot2::ylab("Volume (cubic metres)") +
{if (use_yield) ggplot2::ylab("Yield (mm)")} +
ggplot2::xlab("Year")+
Expand Down Expand Up @@ -246,7 +246,7 @@ plot_annual_cumulative_stats <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(seasons4_data$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(seasons4_data$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))+
ggplot2::ylab("Volume (cubic metres)") +
{if (use_yield) ggplot2::ylab("Yield (mm)")} +
ggplot2::xlab("Year")+
Expand Down Expand Up @@ -292,7 +292,7 @@ plot_annual_cumulative_stats <- function(data,
ggplot2::geom_bar(position = "stack", stat = "identity", na.rm = TRUE, width=1, colour = "black") +
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 6)) +
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()),
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)),
expand = ggplot2::expansion(mult = c(0, 0.05)))+
ggplot2::ylab("Volume (cubic metres)") +
{if (use_yield) ggplot2::ylab("Yield (mm)")} +
Expand Down Expand Up @@ -332,7 +332,7 @@ plot_annual_cumulative_stats <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(seasons2_data$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(seasons2_data$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()),
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)),
expand = ggplot2::expansion(mult = c(0, 0.05)))+
ggplot2::ylab("Volume (cubic metres)") +
{if (use_yield) ggplot2::ylab("Yield (mm)")} +
Expand Down Expand Up @@ -363,7 +363,7 @@ plot_annual_cumulative_stats <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(seasons4_data$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(seasons4_data$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()),
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)),
expand = ggplot2::expansion(mult = c(0, 0.05)))+
ggplot2::ylab("Volume (cubic metres)") +
{if (use_yield) ggplot2::ylab("Yield (mm)")} +
Expand Down
2 changes: 1 addition & 1 deletion R/plot_annual_extremes.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ plot_annual_extremes <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(peak_values$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(peak_values$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale())) +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1))) +
ggplot2::ylab(y_axis_title)+
ggplot2::xlab("Year")+
ggplot2::scale_color_manual(values = colour_list)+
Expand Down
4 changes: 2 additions & 2 deletions R/plot_annual_extremes_year.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ plot_annual_extremes_year <- function(data,
{if(plot_max) ggplot2::geom_point(ggplot2::aes(x= Date, y = Max_Value, fill = high_lab), size = 3.5, na.rm = TRUE, shape = 21) }+
{if(!log_discharge) ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.05)),
breaks = scales::pretty_breaks(n = 8),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}+
{if(log_discharge) ggplot2::scale_y_log10(breaks = scales::log_breaks(n = 8, base = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge & log_ticks) ggplot2::annotation_logticks(base= 10, "left", colour = "grey25", size = 0.3,
short = ggplot2::unit(.07, "cm"), mid = ggplot2::unit(.15, "cm"),
long = ggplot2::unit(.2, "cm"))} +
Expand Down
4 changes: 2 additions & 2 deletions R/plot_annual_flow_timing_year.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ plot_annual_flow_timing_year <- function(data,
ggplot2::aes(y = Value2, fill = Percent), size = 3.5, na.rm = TRUE, shape = 21) +
{if(!log_discharge) ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.05)),
breaks = scales::pretty_breaks(n = 8),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}+
{if(log_discharge) ggplot2::scale_y_log10(breaks = scales::log_breaks(n = 8, base = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge & log_ticks) ggplot2::annotation_logticks(base= 10, "left", colour = "grey25", size = 0.3,
short = ggplot2::unit(.07, "cm"), mid = ggplot2::unit(.15, "cm"),
long = ggplot2::unit(.2, "cm"))} +
Expand Down
2 changes: 1 addition & 1 deletion R/plot_annual_highflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ plot_annual_highflows <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(highflow_values$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(highflow_values$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()),
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)),
expand = ggplot2::expansion(mult = c(0.1, 0.1))) +
ggplot2::ylab(y_axis_title)+
ggplot2::xlab("Year")+
Expand Down
2 changes: 1 addition & 1 deletion R/plot_annual_lowflows.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ plot_annual_lowflows <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(lowflow_values$Year)) < 8) ggplot2::scale_x_continuous(breaks = unique(lowflow_values$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale()),
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)),
expand = ggplot2::expansion(mult = c(0.1, 0.1))) +
ggplot2::ylab(y_axis_title)+
ggplot2::xlab("Year")+
Expand Down
4 changes: 2 additions & 2 deletions R/plot_annual_normal_days_year.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ plot_annual_normal_days_year <- function(data,
ggplot2::geom_point(ggplot2::aes(y = Value, fill = Normal), size = 3, shape = 21, colour = "black") +
{if(!log_discharge) ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.05)),
breaks = scales::pretty_breaks(n = 8),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}+
{if(log_discharge) ggplot2::scale_y_log10(breaks = scales::log_breaks(n = 8, base = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge & log_ticks) ggplot2::annotation_logticks(base = 10, "left", colour = "grey25", size = 0.3,
short = ggplot2::unit(.07, "cm"), mid = ggplot2::unit(.15, "cm"),
long = ggplot2::unit(.2, "cm"))} +
Expand Down
4 changes: 2 additions & 2 deletions R/plot_annual_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ plot_annual_stats <- function(data,
ggplot2::geom_point(na.rm = TRUE, shape = 21, size = 2, colour = "black") +
{if(!log_discharge) ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0, 0.02)),
breaks = scales::pretty_breaks(n = 8),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge) ggplot2::scale_y_log10(expand = ggplot2::expansion(mult = c(0.02, 0.02)),
breaks = scales::log_breaks(n = 8, base = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge & log_ticks) ggplot2::annotation_logticks(
base = 10, "l", colour = "grey25", size = 0.3, short = ggplot2::unit(.07, "cm"),
mid = ggplot2::unit(.15, "cm"), long = ggplot2::unit(.2, "cm"))} +
Expand Down
4 changes: 2 additions & 2 deletions R/plot_annual_stats2.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ plot_annual_stats2 <- function(data,
ggplot2::scale_x_continuous(expand = c(0,0))+
{if(!log_discharge) ggplot2::scale_y_continuous(expand = ggplot2::expansion(mult = c(0.02, 0.02)),
breaks = scales::pretty_breaks(n = 8),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge) ggplot2::scale_y_log10(expand = ggplot2::expansion(mult = c(0.02, 0.02)),
breaks = scales::log_breaks(n = 8, base = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge) ggplot2::annotation_logticks(base= 10, "left", colour = "grey25", size = 0.3,
short = ggplot2::unit(.07, "cm"), mid = ggplot2::unit(.15, "cm"),
long = ggplot2::unit(.2, "cm")) }+
Expand Down
4 changes: 2 additions & 2 deletions R/plot_daily_cumulative_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ plot_daily_cumulative_stats <- function(data,
"5th-25th Percentile", "Min-5th Percentile")) +
ggplot2::scale_color_manual(values = c("Median" = "purple3", "Mean" = "springgreen4")) +
{if (!log_discharge) ggplot2::scale_y_continuous(expand = c(0, 0), breaks = scales::pretty_breaks(n = 7),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}+
{if (log_discharge) ggplot2::scale_y_log10(expand = c(0, 0), breaks = scales::log_breaks(n = 8, base = 10) ,
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}+
{if (log_discharge & log_ticks) ggplot2::annotation_logticks(base= 10, "left", colour = "grey25", size = 0.3,
short = ggplot2::unit(.07, "cm"), mid = ggplot2::unit(.15, "cm"),
long = ggplot2::unit(.2, "cm"))} +
Expand Down
4 changes: 2 additions & 2 deletions R/plot_daily_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ plot_daily_stats <- function(data,
ggplot2::geom_line(ggplot2::aes(y = Median, colour = "Median"), size = .5, na.rm = TRUE) +
ggplot2::geom_line(ggplot2::aes(y = Mean, colour = "Mean"), size = .5, na.rm = TRUE) +
{if(!log_discharge) ggplot2::scale_y_continuous(expand = c(0, 0), breaks = scales::pretty_breaks(n = 8),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))}+
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))}+
{if(log_discharge) ggplot2::scale_y_log10(expand = c(0, 0), breaks = scales::log_breaks(n = 8, base = 10),
labels = scales::label_number(scale_cut = scales::cut_short_scale()))} +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1)))} +
{if(log_discharge & log_ticks) ggplot2::annotation_logticks(base= 10, "left", colour = "grey25", size = 0.3,
short = ggplot2::unit(.07, "cm"), mid = ggplot2::unit(.15, "cm"),
long = ggplot2::unit(.2, "cm"))} +
Expand Down
2 changes: 1 addition & 1 deletion R/plot_data_screening.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ plot_data_screening <- function(data,
ggplot2::scale_x_continuous(breaks = scales::pretty_breaks(n = 8))+
{if(length(unique(flow_summary$Year)) < 5) ggplot2::scale_x_continuous(breaks = unique(flow_summary$Year))}+
ggplot2::scale_y_continuous(breaks = scales::pretty_breaks(n = 6),
labels = scales::label_number(scale_cut = scales::cut_short_scale())) +
labels = scales::label_number(scale_cut = append(scales::cut_short_scale(),1,1))) +
{if (plot_availability) ggplot2::scale_shape_manual(values = c(19,21),
labels = c("Complete Data", "Missing Values"),
name = "Data Availability") } +
Expand Down
Loading

0 comments on commit db3efc7

Please sign in to comment.