Hi,

There's definitely a bug. The linking of view ranges is working fine, but 
it is about the drawing of the axes and labels obviously. I don't have a 
solution, but here are some initial thoughts that might help.

First, I think the top 2x2 grid arrangement has the same problem -- it's 
not just limited to the vertical stack. Also, I don't think linking of the 
axes has anything to do with it either, it just makes it more noticeable 
since there's more plots to see the issue on. The same text drawing issue 
can happen on a single plot as well.

The problem is the text is allowed to draw outside of the axes range, but 
then that region is not being erased when the axes are resized and new 
labels are painted. I don't understand the intricacies of the layout of the 
labels and their width/height boxes to see how or why, but I'm guessing 
it's an issue in the generateDrawSpecs method of AxisItem 
(http://www.pyqtgraph.org/documentation/_modules/pyqtgraph/graphicsItems/AxisItem.html#AxisItem.generateDrawSpecs).

I think there might be some floating point rounding errors that make two 
text labels get drawn at the same tick, and then they overlap. Workaround 
is to not zoom in that much! :) Seriously though, limit the zoom range to 
avoid this, since your data can't be stored/plotted with that much 
precision anyway.

Just to demonstrate, here is the modified example with the axes label 
widths in the 2x2 grid plot fixed, so there's no resizing, but the labels 
can still spill out of their allocated box (most noticeable around where 
the "A" autoscale button lives). The vertical stack is no longer a stack, 
just a single plot, but you can get the same issue happening.

from PyQt5.QtWidgets import QMainWindow, QWidget, QGridLayout
from pyqtgraph import ViewBox, PlotItem
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg

app = QtGui.QApplication([])

window = QMainWindow()
holder = QWidget()
holder_layout = QGridLayout()
holder.setLayout(holder_layout)
window.setCentralWidget(holder)

#
# Grid section
#
grid_widget = pg.GraphicsLayoutWidget()
grid_subplot1 = grid_widget.addPlot(col=0, row=0)
grid_subplot2 = grid_widget.addPlot(col=1, row=0)
grid_subplot3 = grid_widget.addPlot(col=0, row=1)
grid_subplot4 = grid_widget.addPlot(col=1, row=1)
for plotitem in (grid_subplot1, grid_subplot2, grid_subplot3, 
grid_subplot4):
    plotitem.setRange(xRange=(0, 5), yRange=(0, 2.5), padding=0)
    plotitem.showGrid(True, True, 0.2)
    plotitem.getAxis('left').setStyle(autoExpandTextSpace=False, 
tickTextWidth=40)
#
# Grid XLink 1->2,2->3,3-4
#
grid_subplot1.setXLink(grid_subplot2)
grid_subplot2.setXLink(grid_subplot3)
grid_subplot3.setXLink(grid_subplot4)
#
# Vertical section
#
vertical_widget = pg.GraphicsLayoutWidget()
vertical_subplot1 = vertical_widget.addPlot(col=0, row=0)
vertical_subplot1.setRange(xRange=(0, 5), yRange=(0, 2.5), padding=0)
vertical_subplot1.showGrid(True, True, 0.2)

holder_layout.addWidget(grid_widget)
holder_layout.addWidget(vertical_widget)


if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        window.show()
        QtGui.QApplication.instance().exec_()


And a screenshot from above example to show text spilling out to the left 
of the x-axis, and the two labels on same tick. Better to play with the 
demo, but it's a start:

[image: Screenshot from 2018-08-23 12-50-52.png] <about:invalid#zClosurez>

Patrick

On Wednesday, 22 August 2018 18:46:26 UTC+9:30, pojzn wrote:
>
>
> Hello everyone,
>
> I have posted about a problem I'm experiencing when trying to link 
> multiple plots via setXLink, described here 
> <https://github.com/pyqtgraph/pyqtgraph/issues/732>.
> Any ideas or suggestions will be greatly appreciated.
>
> Thank you in advance!
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/31468ba1-ec99-4f28-8112-cc8961d7a27c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to