I have a plugin and I want to symbology a vector file with some default ramp colors but I see that in graduated symbology is not so easy as in graduated symbology.
Is it possible to assign a default ramp color to a vector file?
My code is very confusing because I tried so many examples but I couldn't get the result.
for code, (color, label) in attribute_sym.items(): sym = QgsSymbolV2.defaultSymbol(layer.geometryType()) sym.setColor(QColor(color)) category = QgsRendererCategoryV2(code, sym, label) categories.append(category) self.field = self.dockwidget.comboBox.currentText() renderer = QgsCategorizedSymbolRendererV2(self.field, categories) layer.setRendererV2(renderer) QgsMapLayerRegistry.instance().addMapLayer(layer)
This code works but I don't want to allways define the list with the colors, because I am trying to symbology several fields. Is it some way of using the default ramp colors?