8000 Problems of using sharex options with lines plots and colormesh with colorbar · Issue #12161 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Problems of using sharex options with lines plots and colormesh with colorbar #12161
Closed
@billtau

Description

@billtau

Bug report

Bug summary
I am trying to make a plot with sharex options. There are two subplots, one is just a line plot, and the other is made with pcolormesh, with a colorbar. The use of the colorbar, however, totally messed up the position of the plot from pcolormesh.

Code for reproduction

# Paste your code here
#
#
import matplotlib.pyplot as plt
import numpy as np

plt.close('all')
fig,axes=plt.subplots(2,1,sharex=True)
ax = axes[0]
x = np.linspace(0, 100, 100)
ax.plot(x)

data = np.random.random((50, 100))
ax = axes[1]
plt2=ax.pcolormesh(data)
plt.colorbar(plt2)
plt.show()

Actual outcome
with_cb

Expected outcome
Something like the following, but with a colorbar on the right of the corresponding image.
without_cb

Matplotlib version

  • Operating system: MacOSX
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version: 3.6
  • Jupyter version (if applicable):
  • Other libraries:

matplotlib was installed via Macport

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0