Skip to content

Plot markers: labels and symbols are clipped #82

@luc-j-bourhis

Description

@luc-j-bourhis

Consider the code

from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtCore import Qt
import qwt
import numpy as np

app = QtWidgets.QApplication([])
x = np.linspace(0, 4*np.pi, 100)
y = np.cos(x)
plot = qwt.QwtPlot("Sine function")
plot.enableAxis(plot.xBottom, False) #|Disable axes enabled by default
plot.enableAxis(plot.yLeft, False)   #|
plot.insertLegend(qwt.QwtLegend(), qwt.QwtPlot.BottomLegend)
qwt.QwtPlotCurve.make(x, y, "Sinus", plot, linecolor="blue", antialiased=True)
c = QtGui.QColor('purple')
sz = 10
s = qwt.QwtSymbol.make(
    style=qwt.QwtSymbol.Ellipse,
    brush=QtGui.QBrush(c), pen=QtGui.QPen(c),
    size=QtCore.QSize(sz, sz))
step = 5
for xi, yi in zip(x[::step], y[::step]):
    l = qwt.QwtText.make(text=f'{yi:0.2f}', pointsize=8)
    qwt.QwtPlotMarker.make(
        xvalue=xi, yvalue=yi,
        label=l,
        symbol=s,
        align=Qt.AlignTop,
        plot=plot)
plot.resize(1200, 600)
plot.show()
app.exec_()

and the attached outcomes: the green arrows drawn by hand shows where the circles used as markers and their associated text labels are clipped by the plot boundary. So it seems PythonQwt only make the curve fits but not the rest. I would consider that a bug but then is there a way to work around it?
clipped

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