I want to plot each rgb value for its respective feature of the layer via pyqgis. Atm I struggle to properly implement it for each layer individually. With my current code below, all features get the last color code in row no.3. and therefore they all have the same color instead of every element ist individual one.
I use QGIS 2.8.8 Wien and therefore proposed solutions for QGIS 3 do not work properly.
b = iface.activeLayer() symbols = b.rendererV2().symbols() symbol = symbols for f in b.getFeatures(): expr = f['rgb'] express = "color_rgb("+str(expr) +")" symbol.symbolLayer(0).setDataDefinedProperty('color', express) b.triggerRepaint() iface.legendInterface().refreshLayerSymbology(b)