开发者

Customize Color Using Lighter in BarChart

Please Consider :

 dalist = {{901, 503, 522, 1305}, {910, 512, 477, 1260}, 
           {847, 459, 556, 1275}, {799, 517, 527, 1197}}

 cogColors = {RGBColor[0, 0, 1], RGBColor[1, 0, 0], RGBColor[0, 1, 0], RGBColor[1, 1, 0]}

 BarChart[dalist, ChartStyle -> cogColors]

Customize Color Using Lighter in BarChart

I don`t understand how to assign color to list and to value within the list.

Here my hope is to get each sublist ( first one being : {901, 503, 522, 1305}) assigned one color (Part[[]] of cogColors). Then each bar would be a darker/lighter but similar 开发者_开发百科color. Below is the desired output (ppt) :

Customize Color Using Lighter in BarChart


BarChart[dalist, ChartStyle -> {cogColors, Opacity /@ {0.4, 0.6, 0.8, 1}}]

Customize Color Using Lighter in BarChart

The crux lies in the following sentence in the doc page of ChartStyle:

With the form ChartStyle->{spec_1, spec_2, ...}, the i, j, ... element in a nested list of datasets has a style given by applying spec_1[[i]], then spec_2[[j]], etc.

This means you have to find directives that have cumulative effects. The combination of Opacity and colors has this. If you combine various colors you end up with the last one.


BarChart[MapThread[
  Style, {dalist, 
   Transpose@
    Reverse@NestList[Lighter, {Red, Green, Blue, Yellow}, 3]}, 2]]

Customize Color Using Lighter in BarChart

Edit by Verbeia

You can use Blend and this approach of MapThread and Style to get whatever color combinations you want, eg:

extColours = 
 Outer[Blend[{#1, GrayLevel[0.1]}, #2] &, cogColors, {0.2, 0.4, 0.6, 0.8}];

BarChart[MapThread[Style, {dalist, extColours}, 2]]

Customize Color Using Lighter in BarChart

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜