Repository: pyqtgraph/pyqtgraph

Issue:
Added arrow symbols for the ScatterPlotItem
This commit adds arrows (up, right, down and left) to the ScatterPlotItem's symbol list.

When executing the ScatterPlot example, we can see they are significantly smaller than the rest of the symbols because, as I have seen, the symbols' path is to fit in the 1x1 square centered at (0, 0). Of course the arrows have been implemented to point to the actual point in the scatter plot, which means they only use a small part of that area.

Is there a better way to implement them? I will be glad to change anything if that leads to the acceptance of these symbols in PyQtGraph.



Discussion:

Resolving patch:
diff --git a/examples/ScatterPlot.py b/examples/ScatterPlot.py
--- a/examples/ScatterPlot.py
+++ b/examples/ScatterPlot.py
@@ -83,7 +83,7 @@ def createLabel(label, angle):
 
 s2 = pg.ScatterPlotItem(size=10, pen=pg.mkPen('w'), pxMode=True)
 pos = np.random.normal(size=(2,n), scale=1e-5)
-spots = [{'pos': pos[:,i], 'data': 1, 'brush':pg.intColor(i, n), 'symbol': i%5, 'size': 5+i/10.} for i in range(n)]
+spots = [{'pos': pos[:,i], 'data': 1, 'brush':pg.intColor(i, n), 'symbol': i%10, 'size': 5+i/10.} for i in range(n)]
 s2.addPoints(spots)
 spots = [{'pos': pos[:,i], 'data': 1, 'brush':pg.intColor(i, n), 'symbol': label[1], 'size': label[2]*(5+i/10.)} for (i, label) in [(i, createLabel(*random_str())) for i in range(n)]]
 s2.addPoints(spots)
@@ -120,4 +120,3 @@ def createLabel(label, angle):
     import sys
     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
         QtGui.QApplication.instance().exec_()
-
diff --git a/examples/Symbols.py b/examples/Symbols.py
--- a/examples/Symbols.py
+++ b/examples/Symbols.py
@@ -29,6 +29,10 @@
 plot.plot([8, 9, 10, 11, 12], pen=(237,177,32), symbolBrush=(237,177,32), symbolPen='w', symbol='star', symbolSize=14, name="symbol='star'")
 plot.plot([9, 10, 11, 12, 13], pen=(126,47,142), symbolBrush=(126,47,142), symbolPen='w', symbol='+', symbolSize=14, name="symbol='+'")
 plot.plot([10, 11, 12, 13, 14], pen=(119,172,48), symbolBrush=(119,172,48), symbolPen='w', symbol='d', symbolSize=14, name="symbol='d'")
+plot.plot([11, 12, 13, 14, 15], pen=(253, 216, 53), symbolBrush=(253, 216, 53), symbolPen='w', symbol='arrow_down', symbolSize=22, name="symbol='arrow_down'")
+plot.plot([12, 13, 14, 15, 16], pen=(189, 189, 189), symbolBrush=(189, 189, 189), symbolPen='w', symbol='arrow_left', symbolSize=22, name="symbol='arrow_left'")
+plot.plot([13, 14, 15, 16, 17], pen=(187, 26, 95), symbolBrush=(187, 26, 95), symbolPen='w', symbol='arrow_up', symbolSize=22, name="symbol='arrow_up'")
+plot.plot([14, 15, 16, 17, 18], pen=(248, 187, 208), symbolBrush=(248, 187, 208), symbolPen='w', symbol='arrow_right', symbolSize=22, name="symbol='arrow_right'")
 plot.setXRange(-2, 4)
 
 ## Start Qt event loop unless running in interactive mode or using pyside.
diff --git a/pyqtgraph/graphicsItems/ScatterPlotItem.py b/pyqtgraph/graphicsItems/ScatterPlotItem.py
--- a/pyqtgraph/graphicsItems/ScatterPlotItem.py
+++ b/pyqtgraph/graphicsItems/ScatterPlotItem.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from itertools import starmap, repeat
 try:
     from itertools import imap
@@ -20,7 +21,9 @@
 
 
 ## Build all symbol paths
-Symbols = OrderedDict([(name, QtGui.QPainterPath()) for name in ['o', 's', 't', 't1', 't2', 't3','d', '+', 'x', 'p', 'h', 'star']])
+name_list = ['o', 's', 't', 't1', 't2', 't3', 'd', '+', 'x', 'p', 'h', 'star',
+             'arrow_up', 'arrow_right', 'arrow_down', 'arrow_left']
+Symbols = OrderedDict([(name, QtGui.QPainterPath()) for name in name_list])
 Symbols['o'].addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1))
 Symbols['s'].addRect(QtCore.QRectF(-0.5, -0.5, 1, 1))
 coords = {
@@ -41,7 +44,11 @@
     'star': [(0, -0.5), (-0.1123, -0.1545), (-0.4755, -0.1545),
              (-0.1816, 0.059), (-0.2939, 0.4045), (0, 0.1910),
              (0.2939, 0.4045), (0.1816, 0.059), (0.4755, -0.1545),
-             (0.1123, -0.1545)]
+             (0.1123, -0.1545)],
+    'arrow_down': [
+        (-0.125, 0.125), (0, 0), (0.125, 0.125),
+        (0.05, 0.125), (0.05, 0.5), (-0.05, 0.5), (-0.05, 0.125)
+    ]
 }
 for k, c in coords.items():
     Symbols[k].moveTo(*c[0])
@@ -51,7 +58,10 @@
 tr = QtGui.QTransform()
 tr.rotate(45)
 Symbols['x'] = tr.map(Symbols['+'])
-
+tr.rotate(45)
+Symbols['arrow_right'] = tr.map(Symbols['arrow_down'])
+Symbols['arrow_up'] = tr.map(Symbols['arrow_right'])
+Symbols['arrow_left'] = tr.map(Symbols['arrow_up'])
 
 def drawSymbol(painter, symbol, size, pen, brush):
     if symbol is None:


Test patch: