Plotting scatterplots with pairs in R, in log scale with data containing zeros

◇◆丶佛笑我妖孽 提交于 2019-12-20 01:38:59

问题


I am trying to plot some pairs of scatterplots using "pairs". My dataframe look like :

    >e
    X Y Z
    0 0 0
    2 3 4
    0 3 4
    3 3 3

A completely standard dataframe here.

I use this to plot my scatter plots, again nothing fancy:

pairs(~X+Y+Z, data=e, log="xy")

It works great, but it doesn't plot the labels. However if I remove the log="xy" in the command, then the labels are plotted nicely. So I guess it has to do with the fact that I want my scatterplots to be in log scale.

So my question is what shall I do? Shall I remove all lines with zeros in it before hand (how do you do that?) Is there a magic trick that will let me have log="xy" and my scatterplots labeled?

Please let me know if it is not clear.


回答1:


You ignored this (where I called your data frame DF):

R> pairs(~X+Y+Z, data=df, log="xy")
There were 30 warnings (use warnings() to see them)

and if you look at these thirty warnings, you will see that

  • you cannot plot data containing zeros on a log scale (and I guess you know why)

  • log is not a recognised parameter for pairs()

So if you want a pairs plot in logs, you may have to takes logs yourself (and either add a small epsilon or use a transformation like log(1 + x) and call pairs() on that data.

Edit The easiest is probably pairs(~X+Y+Z, data=log(1+DF))



来源:https://stackoverflow.com/questions/4748636/plotting-scatterplots-with-pairs-in-r-in-log-scale-with-data-containing-zeros

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