This is a followup to this, this, and this question.
Currently, I have a twelve-panel lattice in which the same dark histogram outline is superimposed on twelve different solid gray histograms:
This makes it easy to compare the new data in each panel with the same set of other data. Leaving out some details that are irrelevant to this question, my code looks like this:
histogram(~ foo | bar,
data=mydata[mydata$bar!="none",], # get only the 12 categories
col=mylightgray, border=mylightgray,
panel=function(...){panel.histogram(...) # add histogram to ea. panel:
panel.histogram(x=mydata[mydata$bar=="none",]$foo,
col="transparent", border="black")})
Now I want to reverse the colors, so to speak: I want to superimpose different outline histograms on the same solid gray histogram.
Here's the problem:
If I simply swap the colors, so that the main histogram has col="transparent"
and border="black"
, while the panel function histogram uses mylightgray
, the gray histograms will be on top, and will obscure parts of the outline histogram, which defeats the purpose of putting two histograms in one panel.
On the other hand, if I swap the data specification, so that the outer main histogram uses bar=="none"
and the panel histogram uses bar!="none"
, I only get one panel.
The problem is that it's the main histogram call, not the extra panel function, that both writes first and also controls the number of panels. It appears to be impossible to create multiple panels in which the plot that's on the bottom is the same--unless I just create a dataframe with twelve duplicates of the same data. I wonder if there's a solution without producing special data.