I have a whole set of maps that have graduated colors based on a set ramp and I also like to change the symbol sizes as it makes anomalous areas stand out even more. Id like to change the symbol sizes with the console (if I use the automatic classification by value the symbol sizes are reset).
In QGIS 2.18 I could do it by:
layer = qgis.utils.iface.mapCanvas().currentLayer() symbols = layer.rendererV2().symbols() symbols.setSize(1.5) symbols.setSize(1.75) symbols.setSize(2) symbols.setSize(2.25) symbols.setSize(2.5) symbols.setSize(2.75)
In QGIS 3 the
rendererV2 has been renamed (to renderer), but I am stuck on how to call the symbols. I know its likely a python 3 syntax I am missing, but it hangs on
symbols = layer.rendererV2().symbols() TypeError: symbols(self, context: QgsRenderContext): not enough arguments
I did manage to get at the symbols a different way:
layer = qgis.utils.iface.mapCanvas().currentLayer() renderer = layer.renderer() renderer.ranges().symbol().size() ranges = renderer.ranges() ranges.symbol().size()
but if I do:
it does not actually change anything and a layer refresh does not help. If I query the size again it tells me the original size, and I guess it is the default value the graduated renderer is using.
In the change log for v3,
QgsSymbolLayer (renamed from
usedAttributes() now requires a
I've been poking at this for a long time and I feel I am close, but I just am not familiar enough with python to get over this hurdle.