I want to do this in PyQGIS. Here is an example of how I would symbolize my layer:
uri = '/Users/ep9k/Desktop/SandraMonson/TestZips.shp' join_layer = iface.addVectorLayer(uri, 'Patients by Zip Code', 'ogr') target_field = 'Patient_Da' def apply_graduated_symbology(): myRangeList =  symbol = QgsSymbol.defaultSymbol(join_layer.geometryType()) symbol.setColor(QColor("#f5c9c9")) myRange = QgsRendererRange(0, 3, symbol, '0-3') myRangeList.append(myRange) myRenderer = QgsGraduatedSymbolRenderer(target_field, myRangeList) myRenderer.setMode(QgsGraduatedSymbolRenderer.Custom) join_layer.setRenderer(myRenderer) print(f"Graduated color scheme applied") apply_graduated_symbology()
The class QgsRendererRangeLabelFormat seems to be what I need to control the precision of these labels, as it has a method
What I do not understand is, it seems QgsRendererRange and QgsRendererRangeLabelFormat have no relationship to each other according to the documentation, the PyQGIS console, etc. In fact, QgsRenderRangeLabelFormat seems to have no parent or child classes and I can't figure out how this class relates to anything else.
It seems like I should be able to do something like this:
label = QgsRendererRangeLabelFormat('0-3', 2) #2nd argument sets the precision myRange = QgsRendererRange(0, 3, symbol, label)
But this really doesn't make sense because I create a string ('0-3') and then setPrecision, which should affect the precision of a float.
How do I use the class QgsRendererRangeLabelFormat?