Include unused factor levels on the verge of ggplot2

Is there a way to enable the panel for unused levels of the factor used in the cut?

The reason I want to do this is because I arrange several separate graphs in rows showing different measures, with each row having the same number of panels facet_gridin columns. Each chart must contain a column.

But when the data for one of the rows does not contain data for a certain level of the face, the number of panels will be different, and the columns will not line up. For example, note that the "Mathematics II" panel is missing on the last line:

Example plot http://dl.dropbox.com/u/14792859/ggplot2%20facet%20levels.png

The only thing I can think of is to include a dummy data point for any missing facet levels, but I would like to hear that there is a simpler / cleaner way.

+3
source share
1 answer

As Ben Bolker mentioned, this seems to be a bug in ggplot2, caused by a bug in plyr. This will be fixed in the upcoming release of plyr 1.5.

At the same time, I worked on the problem by creating a separate plot and using facet_grid, with lines defining the various parameters that should be built. The problem is that I cannot specify a different scale_fill_manual for the two lower panels, so instead I used the stroke color for the middle panel - not perfect, but good enough.

, .

+3

Source: https://habr.com/ru/post/1792954/


All Articles