R - Setting margins does not work

牧云@^-^@ 提交于 2021-01-27 12:43:23

问题


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.


回答1:


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".



来源:https://stackoverflow.com/questions/48117003/r-setting-margins-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!