Skip to content

BarGraphItem is not showing if bar coordinates are huge #2550

@noonchen

Description

@noonchen

Short description

See example below, use data to create a BarGraphItem, there will be nothing, whereas use data_ok everything is normal.

Code to reproduce

"""
Simple example using BarGraphItem
"""

import numpy as np
import pyqtgraph as pg

win = pg.plot()
win.setWindowTitle('pyqtgraph example: BarGraphItem')

# prepare data

# bars are invisible, might show up when resizing
data = np.random.randint(2E9, 4E9, 1000)

# # if data is not very big, everything is fine
# data_ok = np.random.randint(200, 400, 1000)

counts, edges = np.histogram(data, bins=50)
height = edges[1]-edges[0]
bg1 = pg.BarGraphItem(x0=0, y=edges[:-1], height=height, width=counts, brush='r')
# set viewbox range
vb = win.getPlotItem().getViewBox()
vb.setLimits(xMin=0, 
             xMax=counts.max() * 1.2,
             yMin=edges[0] * 0.9, 
             yMax=edges[-1] * 1.1)

win.addItem(bg1)

if __name__ == '__main__':
    pg.exec()

Real behavior

Blank scene.
image

Tested environment(s)

  • PyQtGraph version: 0.13.1
  • Qt Python binding: PyQt5 5.15.4 Qt 5.15.2
  • Python version: 3.9
  • NumPy version: 1.20.3
  • Operating system: macOS
  • Installation method: pip

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