Based on this code below, is it possible to use Random Color option in Symbology?
layer = iface.activeLayer()
field_name = 'zona_manejo'
field_index = layer.fields().indexFromName(field_name)
unique_values = layer.uniqueValues(field_index)
category_list = []
for value in unique_values:
symbol = QgsSymbol.defaultSymbol(layer.geometryType())
category = QgsRendererCategory(value, symbol, str(value))
category_list.append(category)
renderer = QgsCategorizedSymbolRenderer(field_name, category_list)
style = QgsStyle().defaultStyle()
ramp = style.colorRamp('Greens')
renderer.updateColorRamp(ramp)
layer.setRenderer(renderer)
layer.triggerRepaint()
In this case I'm using 'Greens' color ramp, but I'd like to set "Random colors' as this "Color ramp" UI option.