I'm using a QgsSingleSymbolRenderer
to display various points and lines etc for a Line geometry.
I have a Single symbol
symbology to display the last vertex as a: Line > Marker line > Marker > Simple marker
which I'd like to colour according to one of the pre-defined colour ramps (e.g. Blues, with range between 0 - 100, based on an attribute value "count"), using PyQGIS.
I can do this manually in QGIS by opening the layer's properties and going to > Symbology > Line > Marker line > Marker > Simple marker
where I can use the colour assistant to set the symbols fill colour based on the value of "count". Is it possible to do this using PyQGIS? A snippet of my current code looks something like:
# Define symbol layers
symbol_layers = QgsSymbol.defaultSymbol(vector_layer.geometryType())
symbol_layers.changeSymbolLayer(0, simple_line_symbol_layer)
symbol_layers.insertSymbolLayer(1, last_vertex_simple_marker_symbol_layer)
# Create renderer based on symbol layers, and apply to vector layer
renderer = QgsSingleSymbolRenderer(symbol_layers)
vector_layer.setRenderer(renderer)
No comments:
Post a Comment