Search code examples
rggplot2panel-data

How to force panelView to change linewidth, when there is no option in the package?


I would like to change some graphical features of a panelView plot. In the help menu, I did not find a corresponding option.

I'm not so much into package programming. But I guess they build up on other packages. Perhaps panelView uses ggplot2 or something similar which could be accessed with a workaround? Can I somehow adjust aesthetics?

Here is the MWE from the package. In this case, lines are too thin.

library(panelView) 
data(panelView) 
panelView(turnout ~ 1 + policy_mail_in + policy_motor, type="outcome",  
data = turnout, index = c("abb","year"))

enter image description here


Solution

  • If you look at the source code for panelView, you can see that it hard codes the line width at 0.5. The panelView function does nothing too fancy (like require internals), so you could modify the function so that there is a line width argument. A hacky solution but there is it.

    I have done so, but the function is >1300 lines of code, so I'm not doing to repost it here. Rather, you can copy from here.

    Now, using the panelView_B function, with the new argument, line.width, we can modify the lines:

    library(panelView) 
    data(panelView) 
    panelView_B(turnout ~ 1 + policy_mail_in + policy_motor, type="outcome",  
              data = turnout, index = c("abb","year"), line.width = 1)
    

    enter image description here