开发者

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

开发者 https://www.devze.com 2023-02-05 13:05 出处:网络
I am trying to plot some pairs of scatterplots using \"pairs\". My dataframe look like : >e X Y Z 0 0 0

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 ha开发者_如何学Pythonnd (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.


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))

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号