Hello,

I am very new to Python and to Pyqtgraph.

Below I have a simple plotting function.  I supply x and y data vectors 
(numbers) and a title and I get a plot.

However, my data'x values are actually text and not numbers.  In one case 
the text labels are date with time.  In another case the text contains 
descriptive text to label categories of a histogram.

I've scanned the documentation, which doesn't seem very complete and cannot 
find an obvious way to plot either the x or the y data if it contains text 
(string values) instead of numbers.

Only idea I have come up with, shown, below, is to add (for example) the 
xLabel argument.  Then make a text item for each text label on the axis.

Below, I only plot every 100th text label (of possible tens of thousands). 
 The problem is that if the plot window size is changed, or the zoom level 
of the plot in the window is changed, then every 100th text label is no 
longer appropriate.

I think I need to be able to detect when the plot window size or plot zoom 
level is changed, and based on those parameters, calculate how many of the 
text labels can nicely be shown on the plot axis.  (If I zoom in far enough 
I want to see all text labels corresponding to data shown in the plot 
window, etc.

Apparently, from the documentation, I need to define a: signal, event or a 
slot (what's the difference anyway) to detect a change in zoom level or 
size, then read the new parameters (zoom level, size, etc), make the 
calculation and redraw the text.

Can anyone tell me how to correctly accomplish this?  I don't even know 
where to start reading to understand what to do; and honestly I don't think 
I have that much time left for this.

Or, is there a better way to accomplish how I need to make the plot axes_

Thanks,

Manfred.


import pyqtgraph as pg
def simple_plot(x, y, plotTitle, xLabel = None):
    """  Make a basic plot with title.
    """
    plotWidget = pg.plot(title = plotTitle)
    plotWidget.plot(x, y)
    plotWidget.showGrid(x=True, y=True, alpha=100.0)
    #
    if len(xLabel):
        for i in np.arange(0, len(xLabel), 100):
            text = pg.TextItem(str(xLabel[i]), anchor=(0.3,-0.5), angle=90)
            plotWidget.addItem(text)
            text.setPos(i, 0)


-- 
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/45235bfa-db24-4dd6-b2d9-2c1db13bc1a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to