Jae-Joon Lee | 18 Sep 00:56

color mix

Hello,

Attached is a small patch to add a simple color mix operation support.
For example, "red!30!white" mixes 30% of red with 70% of white. The
syntax is borrowed from latex xcolor package
(http://www.ukern.de/tex/xcolor.html).
I found it quite handy with the fancy box thing.

plt.text(0.6, 0.5, "test", size=50, rotation=30.,
         bbox = dict(boxstyle="round",
                     fc="orange!20!white", # 20% orange + 80% white
                     ec="orange!50!white", # 50 % orange + 50% white
                     )
         )

plt.text(0.5, 0.4, "test", size=50, rotation=-30.,
         bbox = dict(boxstyle="square",
                     fc="aqua!50!green!20!white",
                     ec="green!40!white",
                     )
         )

Any chance this could be included in matplotlib?
Regards,

-JJ
Attachment (color_mix.diff): text/x-diff, 1415 bytes
(Continue reading)

Michael Droettboom | 18 Sep 15:35
Gravatar

Re: color mix

That's a cool feature, and one I have not come across before.

I hesitate slightly because this it is non-standard (by that, I mean not 
available in a lot of "mainstream" formats like CSS, SVG etc.), but 
maybe that's just because they aren't as cool as matplotlib... ;)  The 
nice thing is that the "!" isn't meaningful in color strings at present, 
so this new syntax is at least unambiguous with anything pre-existing.

I'm for it, but would like to hear from others first.

Cheers,
Mike

Jae-Joon Lee wrote:
> Hello,
>
> Attached is a small patch to add a simple color mix operation support.
> For example, "red!30!white" mixes 30% of red with 70% of white. The
> syntax is borrowed from latex xcolor package
> (http://www.ukern.de/tex/xcolor.html).
> I found it quite handy with the fancy box thing.
>
> plt.text(0.6, 0.5, "test", size=50, rotation=30.,
>          bbox = dict(boxstyle="round",
>                      fc="orange!20!white", # 20% orange + 80% white
>                      ec="orange!50!white", # 50 % orange + 50% white
>                      )
>          )
>
> plt.text(0.5, 0.4, "test", size=50, rotation=-30.,
(Continue reading)

John Hunter | 18 Sep 15:47
Gravatar

Re: color mix

On Thu, Sep 18, 2008 at 8:35 AM, Michael Droettboom <mdroe@...> wrote:
> That's a cool feature, and one I have not come across before.
>
> I hesitate slightly because this it is non-standard (by that, I mean not
> available in a lot of "mainstream" formats like CSS, SVG etc.), but
> maybe that's just because they aren't as cool as matplotlib... ;)  The
> nice thing is that the "!" isn't meaningful in color strings at present,
> so this new syntax is at least unambiguous with anything pre-existing.
>
> I'm for it, but would like to hear from others first.

I like it too -- I only ask Jae-Joon that you make sure it is properly
documented, eg in the matplotlib.colors docstring.  What would be
really nice would be a section in doc/users_guide on mpl colors....

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Jae-Joon Lee | 18 Sep 19:32

Re: color mix

Thanks for the positive feedback!
Okay, I'll add a proper documentation for it and upload the patch again.

-JJ

On Thu, Sep 18, 2008 at 9:47 AM, John Hunter <jdh2358@...> wrote:
> On Thu, Sep 18, 2008 at 8:35 AM, Michael Droettboom <mdroe@...> wrote:
>> That's a cool feature, and one I have not come across before.
>>
>> I hesitate slightly because this it is non-standard (by that, I mean not
>> available in a lot of "mainstream" formats like CSS, SVG etc.), but
>> maybe that's just because they aren't as cool as matplotlib... ;)  The
>> nice thing is that the "!" isn't meaningful in color strings at present,
>> so this new syntax is at least unambiguous with anything pre-existing.
>>
>> I'm for it, but would like to hear from others first.
>
> I like it too -- I only ask Jae-Joon that you make sure it is properly
> documented, eg in the matplotlib.colors docstring.  What would be
> really nice would be a section in doc/users_guide on mpl colors....
>
> JDH
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
(Continue reading)

Jouni K. Seppänen | 18 Sep 20:40
Face
Favicon
Gravatar

Re: color mix

Michael Droettboom <mdroe@...> writes:

> That's a cool feature, and one I have not come across before.

I agree that it's a neat idea. However, I would prefer a way to specify
color mixtures that is not based on parsing strings but on Python data
structures, e.g. instead of

>>                      fc="orange!20!white", # 20% orange + 80% white

I would prefer something like the following options:

    fc={'orange': 20, 'white': None}
    fc=[[20, 'orange'], [None, 'white']]
    fc=ColorMixture('orange', 20, 'white') # where ColorMixture is a fairly
                                           # trivial class

This way we could make mixtures of any color specifications. (What if
you wanted to specify a mixture of mixtures? This situation might not
arise in user code directly, but what if the user is programmatically
creating colors?)

>>                      fc="aqua!50!green!20!white",

So this would be something like

    fc={'aqua': 50, 'green': 20, 'white': None}
    fc=[[50, 'aqua'], [20, 'green'], [None, 'white']]
    fc=ColorMixture('aqua', 50, 'green', 20, 'white')

(Continue reading)


Gmane