Skip to contents

Removes the curves and envelope from a plot made by make_plot() and draws new ones, keeping the data points and the plot's other settings. This is quicker than redrawing the whole plot, e.g. as parameter values change.

Usage

update_plot_curve(
  model,
  plot,
  curve.df = NULL,
  extra.curve = NULL,
  plot.transformation = "standard",
  conf.int = FALSE,
  y.range = NULL,
  palette = "Set1"
)

Arguments

model

The model's code, as used to make plot.

plot

A plot made by make_plot().

curve.df

The new curve, from make_curve(). Optional. Without it, the plot is left with no curve.

extra.curve

A new extra curve, drawn in black. Optional.

plot.transformation

The transformation that plot was made with (default "standard"). It must match, because the new curve is transformed in the same way. A "direct" plot has no curves to replace.

conf.int

If TRUE, shade the envelope from curve.df (see make_plot()). Default FALSE.

y.range

The y-axis limits, a numeric vector of two values. Default NULL.

palette

The colour palette that plot was made with (default "Set1").

Value

The updated ggplot object.

Author

Haig Bishop

Examples

set.seed(1)
mm <- simulate_data("MM", list(Km = 0.5, Vmax = 2), x.min = 0.1, x.max = 5,
                    n.samples = 8)
p <- make_plot("MM", data.df = mm,
               curve.df = make_curve("MM", list(Km = 0.5, Vmax = 2), 0, 5))
update_plot_curve("MM", p,
                  curve.df = make_curve("MM", list(Km = 1, Vmax = 2.5), 0, 5))