title: Plotting factor-by-curve tensor product smooths of mgcv::gam
body: <p>So I have a statistical model in which I am using factor-by-curves, i.e., fitting separate smoothing curves for some categories, as in the following. (I'm not paying much attention to the data/model's meaning, just using it as a minimal example.)</p>
  
  <pre><code>library(dplyr)
  library(qgam)
  library(mgcv)
  data(UKload)
  test &lt;- gam(
    NetDemand ~ te(wM, Posan, by = Year), 
    data = UKload %&gt;% mutate(Year = as.factor(Year))
  )
  </code></pre>
  
  <p>When I was simply doing smoothing curves by <code>s</code> instead of tensors, I was happy to use <code>visreg</code> package as follows:</p>
  
  <pre><code>library(visreg)
  test2 &lt;- gam(
    NetDemand ~ s(wM, by = Year),
    data = UKload %&gt;% mutate(Year = as.factor(Year))
  )
  visreg(test2, xvar = "wM", by = "Year")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DbZXE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DbZXE.png" alt="enter image description here"></a></p>
  
  <p>However, I don't seem to be able to do something similar when I am including a tensor---it will simply draw a contour plot with full data, instead of having it partitioned by the factor variable of interest:</p>
  
  <pre><code>visreg2d(test, xvar = "wM", yvar = "Posan", by = "Year")
  </code></pre>
  
  <blockquote>
    <p>Warning message:
    In title(...) : "by" is not a graphical parameter</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/yv87R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yv87R.png" alt="enter image description here"></a></p>
  
  <p>I can do the <code>mgcv::vis.gam</code> with a condition:</p>
  
  <pre><code>vis.gam(test, plot.type = "contour", cond = list(Year = 2011))
  </code></pre>
  
  <p>and later aggregate the plots by <code>Rmisc::multiplot</code> or base <code>plot</code>, but I'm not too happy with these solutions, both in terms of aesthetics and the workflow. Any handy tips on making pretty plots for tensor product smooths with factor-by-curves? </p>