Autoadjust in multichart plot

37 views
Skip to first unread message

DAVID ALEJANDRO PINEDA

unread,
Jun 13, 2022, 5:36:04 PM6/13/22
to pyqtgraph
Hi!

I'm working in a multichart graph in real time, the only problem that i have now is the autoadjust for the widths in some casos didn't happend and I can't found some parameter to set this manually.

The idea is to adjust at same width every chart for every row. Any idea?

Thanks for the help :)

Attach a image and the code.

Captura de pantalla de 2022-06-13 17-32-54.png

Martin Chase

unread,
Jun 13, 2022, 5:58:51 PM6/13/22
to pyqt...@googlegroups.com
Hola David,

Have you tried `setXLink`? Probably somewhere in your `StationLayoutWidget` class, I'm guessing, but it'll work anywhere you have access to all the plots you want linked together. Here's an example: https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/examples/MultiplePlotAxes.py#L23

Buena suerte,
 - Martin (he/him)

DAVID ALEJANDRO PINEDA

unread,
Jun 14, 2022, 9:27:43 AM6/14/22
to pyqt...@googlegroups.com
Hi Martin.

I tried the setXlink and viewbox linkedViewChanged, as is showed at the example link that you shared to me.

Didn't work, mi method to update data and 'view size' is in plot_station.py and is this:

```
    def setData(self, data):
        for name, axis in self.map_axis.items():
            data_axis = data[name]
            curve = getattr(self, axis)
            if curve:
                timelist = [a for a,b  in data_axis]
                valuelist = [b for a,b  in data_axis]
                curve.setData(
                    x=timelist,
                    y=valuelist)
        self.p1.setAutoVisible()
        self.p2.setAutoVisible()
        self.p3.setAutoVisible()
        # self.p2.setGeometry(self.p1.vb.sceneBoundingRect())
        # self.p3.setGeometry(self.p2.vb.sceneBoundingRect())
        self.p2.vb.linkedViewChanged(self.p1.vb, self.p2.vb.XAxis)
        self.p3.vb.linkedViewChanged(self.p2.vb, self.p3.vb.XAxis)
```

The las two lines are, if I understand correctly, the linked to the chart on the left and positionen acordly it.

But the problem can'y be resolved in that way.
This happend when I put more than 10 rows, so ...

There some more mannually form to assign a % for every item in  a row?

Best regards!

David Pineda Osorio
Ingeniero Civil Electricista
Ingeniero en área Geodesia del Centro Sismológico
f: +56 9 82142267


--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/ip_uoZzLTgE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CAD_p8v2YVR%3DDEC47SuiXR9ndTY6XMza7LyDnTZtvrxs5vG8ViQ%40mail.gmail.com.

DAVID ALEJANDRO PINEDA

unread,
Jun 14, 2022, 12:25:41 PM6/14/22
to pyqt...@googlegroups.com
Well, I think solved for the moment with this method.

```
    def updateViewBox(self):
        """
        TODO: More control to adjust charts
        """
        rect = self.parent.viewRect()
        label_rect = self.label.boundingRect()
        w_available = int(.9*((rect.width() - label_rect.width())/3))
        self.plot_station.p1\
            .getAxis("bottom")\
            .setWidth(w_available)
        self.plot_station.p2\
            .getAxis("bottom")\
            .setWidth(w_available)
        self.plot_station.p3\
            .getAxis("bottom")\
            .setWidth(w_available)

```
At the StationLayoutWidget class.




David Pineda Osorio
Ingeniero Civil Electricista
Ingeniero en área Geodesia del Centro Sismológico
f: +56 9 82142267

Reply all
Reply to author
Forward
0 new messages