Skip to content

Scatter autoscaling still has issues with log scaling and zero values #16552

Closed
@moloney

Description

@moloney

I installed the 3.2.0rc3 package, and I can confirm that this fixes almost all the issues with autoscaling and scatter. However, if you have points with 0 for the y-axis and enable log scaling there is still an issue with the scatter plot auto scaling (that doesn't show up with the standard plot function).

import itertools

import numpy as np
from matplotlib import pyplot as plt


x_vals = [4.38462e-06,
          5.54929e-06,
          7.02332e-06,
          8.88889e-06,
          1.125e-05,
          1.42383e-05,
          1.80203e-05,
          2.2807e-05,
          2.88651e-05,
          3.65324e-05,
          4.62363e-05,
          5.85178e-05,
          7.40616e-05,
          9.37342e-05,
          0.000118632,
          ]

y_vals = [0.0,
          0.10000000000000002,
          0.182,
          0.332,
          0.604,
          1.1,
          2.0,
          3.64,
          6.64,
          12.100000000000001,
          22.0,
          39.60000000000001,
          71.3,
          ]

pts = np.array(list(itertools.product(x_vals, y_vals)))

fig = plt.figure("Scatter plot")
ax = fig.gca()
ax.set_xscale('log')
ax.set_yscale('log')
ax.scatter(pts[:,0], pts[:,1]) # This only shows four rows of points

fig = plt.figure("Regular plot")
ax = fig.gca()
ax.set_xscale('log')
ax.set_yscale('log')
ax.plot(pts[:,0], pts[:,1], marker="o", ls="") # This works

plt.show()

Originally posted by @moloney in #6015 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions