Skip to content

Scatter plots with log scaling #15978

Closed
Closed
@Phlya

Description

@Phlya

When using plt.scatter with log-scaled axes, order of calls is important: if axes are set to log scale before plt.scatter is called, margins of the plot are huge:

import matplotlib.pyplot as plt
import numpy as np
f, ax = plt.subplots()
ax.set_xscale('log')
ax.set_yscale('log')
ax.scatter(2**np.arange(10), 2**np.arange(10))

Actual outcome
image

Expected outcome
When plt.scatter is called before axes are set to log scale, it looks normal:

import matplotlib.pyplot as plt
import numpy as np
f, ax = plt.subplots()
ax.scatter(2**np.arange(10), 2**np.arange(10))
ax.set_xscale('log')
ax.set_yscale('log')

image

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.8
  • Jupyter version (if applicable): Jupyter Lab 1.1.4

In some earlier version of matplotlib (or something else) it worked as expected with any order of calls, but now I am getting this problem.

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