[Qgis-developer] Any way to change default colors for vector features?

Martin Dobias wonder.sk at gmail.com
Wed Jan 25 17:58:10 EST 2012


On Wed, Jan 18, 2012 at 7:41 PM, Bob English <bobengl at gmail.com> wrote:
> Hi All,
>
> As mentioned in this forum before, I'm developing a PyQGIS desktop app.  I'm
> using API 1.71 and the V2 renderer.
> see(https://github.com/EcoGIS/CAPS-Scenario-Builder)
>
> For a couple of reasons, my client doesn't like some of the colors that QGIS
> uses by default when loading vector layers.  Is there any method to change
> the list of default colors?

The default colors that QGIS sets to layers are random colors - no
table of default colors is used. If you have a good idea how to
randomly create "nicer" colors, we would like to hear that. This is
how the color are currently chosen:
- in old symbology: all three values (red, green, blue) are rand(0,255)
- in new symbology: the color is constructed from hue (range 0-359),
saturation and value (both range 0-255) with uniform sampling: H =
rand(0,359), S = 64 + rand(0,191), V = 128 + rand(0,127)
where rand(a,b) means a random sample from uniform distribution on
interval [a,b]

It is just a matter of experimenting a bit to find a good range within
the color space that produces better colors.

> I see setColors() : QgsVectorColorBrewerColorRampV2 in the documentation.
> Any chance that the default colors are taken from this?

No, that is not related.

Martin


More information about the Qgis-developer mailing list