0

I used DoseFinds to building the two models and I want to plot both model on the same graph to compare.

library(DoseFinding)
doses <- c(0, 10, 25, 50, 100, 150)
fmodels <- Mods(emax = 25,
            doses=doses, placEff = 0.5, maxEff = -0.4,
            addArgs=list(scal=200))

fmodels2 <- Mods(emax = 25,
            doses=doses, placEff = -1.5, maxEff = -1.4,
            addArgs=list(scal=200))
plot(fmodels)
plot(fmodels2)
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ipkall win
  • 41
  • 4
  • this is not duplicate! i want to plot on the same graph not separate them – ipkall win Aug 22 '14 at 14:43
  • 1
    what class is fmodels? – Señor O Aug 22 '14 at 14:53
  • possible duplicate of [Plot 2 graphs in same plot in R?](http://stackoverflow.com/questions/2564258/plot-2-graphs-in-same-plot-in-r) – Señor O Aug 22 '14 at 14:54
  • 4
    @ipkallwin You are not helping your cause with your outbreaks and personal attacks. Instead you should try to do this yourself and demonstrate some effort. – Roland Aug 22 '14 at 14:55
  • @SeñorO Class "Mods" and the plot method uses lattice. – Roland Aug 22 '14 at 14:59
  • I think this is a better duplicate: http://stackoverflow.com/q/2540129/324364 – joran Aug 22 '14 at 15:04
  • possible duplicate of http://stackoverflow.com/questions/25436551/how-to-plot-two-models-in-the-same-graph – rawr Aug 22 '14 at 15:05
  • Please read the solutions at the link I provided. It is a different question with different solutions. In particular, look at the `gridExtra` answer. – joran Aug 22 '14 at 15:05
  • @joran The asker doesn't want two plots in one window. They want to combine the plot data in one plot. – Roland Aug 22 '14 at 15:07
  • @Roland Are you sure? That wasn't clear to me from the question. – joran Aug 22 '14 at 15:08
  • @joran After looking at the plot from the example in the docs I believe so. It's a facetted lattice plot where each panel shows one type of model. – Roland Aug 22 '14 at 15:09
  • Where `doses <- c(0, 10, 25, 50, 100, 150)` as in the first example in the docs for `Mods`? – Spacedman Aug 22 '14 at 15:10
  • sorry they kept deleting my post, yes there is doses<-c(0...... – ipkall win Aug 22 '14 at 15:35

2 Answers2

4

Combine the two things into one object:

doses <- c(0, 10, 25, 50, 100, 150)
fmodels2 <- Mods(emax = c(25,25),
doses=doses, placEff = c(0.5,-1.5), maxEff = c(-0.4,-1.4),
addArgs=list(scal=200))

then plot with superpose=TRUE:

plot(fmodels2, superpose=TRUE)

enter image description here

The two lines don't overlap much so although it looks like two separate graphs, it isnt!

Spacedman
  • 92,590
  • 12
  • 140
  • 224
1

I guess you want to use superpose = TRUE when you call the plot-function (?plot.Mods). This will plot the models in the same graph if they are in the same Mods-object. See ?Mods for how to have more than one model in the same object.

Jon
  • 56
  • 3