> On May 26, 2021, at 11:12 AM, Ognyan Moore <[email protected]> wrote: > > Hi Israel, > > I think Martin was pointing out that pyqtgraph offers downsampling methods > <https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html#pyqtgraph.PlotDataItem.setDownsampling>which > adjust sampling based on the pixel size of your display. The "peak" > downsample method draws a vertical line between the lowest and highest value > within the range of values that would normally fit onto one pixel.
Sure, and for a basic x-y plot, like a time series, where you have a row of dots along the x-axis, this would work fine. For geospatial data like I have, this would be a total mess - there is no line to connect the dots. Rather, the dots fill the field, and if you remove any of them, then the field will not be filled at any zoom level. Trying to bridge the gap with a line wouldn’t work > The problem with this method is that it assumes all data to be uniformly > spaced in the x-axis, which of course may not be the case. Right, and for geospatial data this is not only not the case, but any given X will have hundreds of data points that cover that X value. Point being that while I’m sure the downsampling methods are good and very useful in general, for my geospatial data it simply doesn’t work. --- Israel Brewster Software Engineer Alaska Volcano Observatory Geophysical Institute - UAF 2156 Koyukuk Drive Fairbanks AK 99775-7320 Work: 907-474-5172 cell: 907-328-9145 > The nice thing about this downsampling method is that it will re-sample for > you as your zoom level changes. > > Ogi > > On Wed, May 26, 2021 at 11:05 AM Israel Brewster <[email protected] > <mailto:[email protected]>> wrote: > Thanks for the suggestions! > >> On May 25, 2021, at 6:24 PM, Martin Chase <[email protected] >> <mailto:[email protected]>> wrote: >> >> Hey Israel, >> >> A couple of thoughts: >> >> Downsampling should be able to make things faster. Look at the >> "optimization" section in >> https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html >> <https://pyqtgraph.readthedocs.io/en/latest/graphicsItems/plotdataitem.html> > I don’t think downsampling is appropriate for my dataset. Since the points > are arranged spatially, any *simple* downsampling would result in holes in > the data coverage. I could, of course *resample* to a larger grid size, but > that would either loose resolution when zoomed in - which we can’t afford, > given that the features we are looking for often are only one or two grid > cells in size - or require periodic re-resampling depending on the zoom, > which doubtless would be more computationally expensive than simply > re-drawing the dataset, not to mention complicated to implement. > >> QGraphicsItems can be cached, which might help with panning. Docs >> https://doc.qt.io/qt-5/qgraphicsitem.html#CacheMode-enum >> <https://doc.qt.io/qt-5/qgraphicsitem.html#CacheMode-enum> > It seems like this should work, based on the description - in fact, it sounds > like it should do essentially what I was suggesting, rendering once to a > offscreen pixmap and then simply using that rendered version. Unfortunately, > I spent some time playing around with the setCacheMode function as well as > the QPixmapCache.setCacheLimit function that the setCacheMode function > mentioned, with no noticeable effect. Which suggests to me that I might be > doing something wrong. > > That said, I also spent a bit more time pursuing my original thought of > rendering the plot to a single pixmap, then just displaying that single > image. As it turned out, once I took a step back from PyQtGraph, implementing > this solution using the base Qt classes/functions turned out to be > surprisingly simple - simplified, no doubt, by the fact that I was already > supplying the symbol brushes to the plot command as a list of QPainterPaths. > So I was able to simply take the x and y coordinates, and use a QPainter to > directly paint the QPainterPaths into a QPixmap, which could then be added to > my plot as a single item. I *did* have to reduce the quality of the rendering > a bit to fit things into memory - so if you zoom in far enough, the > individual data cells have rough edges - but other than that, it seems to > work fine - and performance goes from painfully sluggish on my old machine to > silky smooth. > > There may be other issues with this approach, but so far I haven’t run into > any, at least with my specific application. More testing remains. > > Thanks again! > --- > Israel Brewster > Software Engineer > Alaska Volcano Observatory > Geophysical Institute - UAF > 2156 Koyukuk Drive > Fairbanks AK 99775-7320 > Work: 907-474-5172 > cell: 907-328-9145 > >> >> Others may have more ideas? Let us know if any of that helps! >> >> - Martin >> >> -- >> 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] >> <mailto:[email protected]>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/pyqtgraph/CAD_p8v0iE_jYahUx7o2Oz-u%3DEor8ELyEJK1z53i-3YNvtK-dYw%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/pyqtgraph/CAD_p8v0iE_jYahUx7o2Oz-u%3DEor8ELyEJK1z53i-3YNvtK-dYw%40mail.gmail.com?utm_medium=email&utm_source=footer>. > > > -- > 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] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/233ABF09-0EE0-4AC9-90AD-6BB2586D2AD7%40alaska.edu > > <https://groups.google.com/d/msgid/pyqtgraph/233ABF09-0EE0-4AC9-90AD-6BB2586D2AD7%40alaska.edu?utm_medium=email&utm_source=footer>. > > -- > 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] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/CA%2BnduTGJACsL9ezspJWhBSjtUuXc2Q_LdB-7EeYoH%2B5fKraGOQ%40mail.gmail.com > > <https://groups.google.com/d/msgid/pyqtgraph/CA%2BnduTGJACsL9ezspJWhBSjtUuXc2Q_LdB-7EeYoH%2B5fKraGOQ%40mail.gmail.com?utm_medium=email&utm_source=footer>. -- 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/0726F04E-3304-47CB-AD98-7CCB0ED755E6%40alaska.edu.
