Skip to content

Issue with plotting zeros in log space #4049

Closed

Description

@astrofrog

The following simple example shows an issues with zero values when calling loglog:

import matplotlib.pyplot as plt

nu = [1e2, 1e3, 1e4, 1e5, 1e6, 1e7]
fnu = [1, 1e-30, 1e-45, 0., 0., 0.]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.loglog(nu, fnu, color='blue')
fig.savefig('mpl.png')

The output is:

mpl

Of course, zero is undefined in log space, but I don't understand why it defaults to plotting a value of 0.1 instead. Doing:

fnu = [1, 1e-30, 1e-45, np.nan, np.nan, np.nan]

Does the right thing on the other hand. So maybe the best solution is to replace 0 values by np.nan inside loglog?

I am using matplotlib 1.5.x with Python 3.4.

Activity

  1. mdboom commented on Jan 29, 2015

    @mdboom
    Member

    Puzzling -- the values are masked out in the log scalar and have been for years. Something else is going wrong here. Investigating.

  2. added this to the milestone on Jan 29, 2015
  3. self-assigned this
    on Jan 29, 2015
  4. mdboom commented on Jan 29, 2015

    @mdboom
    Member

    First bad commit is 91725d8 (only affects master). Looking into a solution now.

  5. tacaswell commented on Jan 29, 2015

    @tacaswell
    Member

    I thought I fixed this recently....

  6. tacaswell commented on Jan 29, 2015

    @tacaswell
    Member
  7. astrofrog commented on Jan 29, 2015

    @astrofrog
    ContributorAuthor

    Great, thanks! That does indeed seem to be the same issue.

  8. tacaswell commented on Jan 29, 2015

    @tacaswell
    Member

    This is a duplicate of #3998

  9. mdboom commented on Jan 29, 2015

    @mdboom
    Member

    Sorry I missed that duplicate. I have a few comments about the solution over at #4008...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions