11from PyQt5 import QtWidgets
22from PyQt5 .QtCore import pyqtSlot
3- from pyqtgraph import PlotWidget , plot , GridItem , LegendItem
3+ from pyqtgraph import GridItem
44import pyqtgraph as pg
55
66COLOR_OFFSET = 15
@@ -24,14 +24,15 @@ def create_2d_plot(self):
2424 #self.graphWidget.setBackground("w")
2525 self .graphWidget .hideAxis ('bottom' )
2626 self .graphWidget .hideAxis ('left' )
27- self .graphWidget .setXRange (- 7 , 7 )
28- self .graphWidget .setYRange (- 7 , 7 )
27+ self .graphWidget .setXRange (- 5 , 5 )
28+ self .graphWidget .setYRange (- 5 , 5 )
2929 self .graphWidget .setMouseEnabled (x = False , y = False )
30- self .graphWidget .addLegend ()
30+ self .graphWidget .addLegend (labelTextSize = '24pt' )
3131 self .layout .addWidget (self .graphWidget )
3232
3333 def create_grid (self ):
3434 self .grid = GridItem (pen = 'white' , textPen = 'white' )
35+ self .grid .setTickSpacing ([1.0 ], [1.0 ])
3536 self .graphWidget .addItem (self .grid )
3637
3738 def create_scatter_element (self ):
@@ -40,7 +41,7 @@ def create_scatter_element(self):
4041 'pen' : {'color' : 'w' , 'width' : 1 },
4142 'brush' : pg .intColor (10 , 100 ), # Orange
4243 'symbol' : 'd' ,
43- 'size' : 30 }
44+ 'size' : 50 }
4445 self .base .addPoints ([base_symbol ])
4546 self .graphWidget .addItem (self .base )
4647
@@ -57,7 +58,7 @@ def update_point(self, neighbor_id: int, x: float, y: float):
5758 # 100 is the number int values for the color spectrum,
5859 # COLOR_OFFSET is the offset to apply to have 6 different values for points
5960 'brush' : pg .intColor (neighbor_id * COLOR_OFFSET , 100 ),
60- 'size' : 20 }
61+ 'size' : 50 }
6162 self .scatters [neighbor_id ]["scatter" ].setData (spots = [self .scatters [neighbor_id ]["spot" ]],
6263 name = f"Agent { neighbor_id } " )
6364
0 commit comments