Creating legend with new data defined symbols functionality in QGIS?

Legends for data-defined symbology are not implemented yet. There is an open bug report/feature request: https://issues.qgis.org/issues/11491

Thinking about it, data-defined symbology is extremely powerful and might result in hundreds of different variations of a symbol in color, shape, size, rotation, and so on. It might be unfeasible to really have a legend in such a case.


Update 2017-08:

QGIS3 will include an automatic legend for data-defined size:

enter image description here


I'm not sure it can be of any use for complex cases, but I manage to get a fake legend by adding a shape layer.

I then created points in the new layer with the same kind of data than used to defined the symbology, and located where I wanted the legend to appear. Then I defined the same symbology for this layer, and showed the corresponding data values as labels.


I had to create a legend for a categorized symbology based on data defined color. QGIS 3 did not solve it for me. So I created a attribute containing the catagory value concatenate to the color hexa code.

I created a random categorized style for this column, exported this style to sld file and then manipulate it with regexp into a text editor to replace for each rule the filling color code by the code mentionned in the category name. After that I cleaned the cataegory value and the name of the filtered column and I finally apllied that new style to my layer.

Sorry the link above is in french.

http://si.cenlr.org/24-11-2017