Abhishek Bhatia
Abhishek Bhatia

Reputation: 9814

Log-log plot point not showing

I am trying to a log-log plot of enter image description here

Somehow points disappear somehow I don't understand why: enter image description here

Code:

    fig = plt.figure();
    ax=plt.gca() 
    ax.scatter(x,y,c="blue",alpha=0.95,edgecolors='none')
    ax.set_yscale('log')
    ax.set_xscale('log')

Data:

    (Pdb) print x,y
    [29, 36, 8, 32, 11, 60, 16, 242, 36, 115, 5, 102, 3, 16, 71, 0, 0, 21, 347, 19, 12, 162, 11, 224, 20, 1, 14, 6, 3, 346, 73, 51, 42, 37, 251, 21, 100, 11, 53, 118, 82, 113, 21, 0, 42, 42, 105, 9, 96, 93, 39, 66, 66, 33, 354, 16, 602]
     `[310000, 150000, 70000, 30000, 50000, 150000, 2000, 12000, 2500, 10000, 12000, 500, 3000, 25000, 400, 2000, 15000, 30000, 150000, 4500, 1500, 10000, 60000, 50000, 15000, 30000, 3500, 4730, 3000, 30000, 70000, 15000, 80000, 85000, 2200]

Can I get the log scale values also. I want to compute correlation.

Upvotes: 2

Views: 2283

Answers (1)

Kevin Johnson
Kevin Johnson

Reputation: 613

If you have some data with either x=0 or y=0 you won't be able to print those points on a log-log-plot as log(0) is undefined. However, using:

ax.set_yscale('symlog')
ax.set_xscale('symlog')

will allow you to see points a x=0 or y=0. There's a good explanation of the abilities of 'symlog' here.

Upvotes: 1

Related Questions