3

I estimated a linear regression model by using the quantreg package. I now want to display the results graphically by using the plot() function:

plottest = plot(summary(QReg_final), parm=2,  main="y",ylab="jjjjj")

The result is the following (I can only link the image yet):

Example

As you can see at the very left, the description of the y-axis is cut off. I then tried to adjust the margin parameters, but it seems to have zero influence on the plot. For example:

par(mar=c(10,10,2,2)) 

When I now run the above mentioned code, it results in the exact same plot. On the other hand, when plotting simple data (and not summary() of a quantile regression rq()) the margins are adjusted and the plot displays the new vector of margins.

I would appreciate help on this. Thank you.

shenflow
  • 345
  • 2
  • 12
  • It's easier to help if you supply a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) show where exactly you tried to set `par()` in relation to your plotting code. Also `par()` only works for base graphics functions and it's possible that `quantreg` uses non-base plotting functions. – MrFlick Jan 05 '18 at 15:59
  • Instead of using `par` try adding `mar=c(10,10,2,2)` directly in the `plot` statement. – G5W Jan 05 '18 at 16:00
  • @MrFlick thank you for the reminder, I will do next time. The problem is solved now so I guess there is no need. – shenflow Jan 06 '18 at 10:36
  • @G5W that worked! Thank you - why does this work? – shenflow Jan 06 '18 at 10:36

1 Answers1

3

Instead of using par put mar=c(10,10,2,2) directly in the plot statement.

Many R packages provide customized versions of plot for their objects and these customized versions may set some of the graphical parameters. If you look at the documentation for plot.summary.rqs, it has its own mar parameter. If you set mar within the function call, it passes your value through to the base graphics plot. But if you set it using par, the customized plot overrides your setting. The documentation says "Suitable defaults are chosen based on the coefficients to be visualized".

G5W
  • 36,531
  • 10
  • 47
  • 80