On Tue, Mar 24, 2009 at 11:03 AM, Jason Grout
<jason-s...@creativetrax.com> wrote:
>
> William Stein wrote:
>> On Tue, Mar 24, 2009 at 9:27 AM, Jason Grout
>> <jason-s...@creativetrax.com> wrote:
>>> Jose Guzman wrote:
>>>> kcrisman wrote:
>>>>>> In looking at your code, I had an idea about specifying colors.  Why
>>>>>> don't we have some default color objects defined in Sage, like red,
>>>>>> blue, yellow, green, etc.  Methods could include .darker(), .lighter(),
>>>>>> etc.  So you could specify a plot as:
>>>>>>
>>>>>> plot(x^2, (x,0,1), color=red)
>>>>>> plot(x^3, (x,0,1), color=blue.darker())
>>>>>> plot(x^4, (x,0,1), color=green.lighter())
>>>>>> plot(x^5, (x,0,1), color=red+blue) #gives purple :)
>>>>>>
>>>>>> and then for the more esoteric names (all of the standard web colors,
>>>>>> all of the standard x11 colors, etc.), use the color namespace.
>>>>>>
>>>>>> plot(sin(x), (x,0,1), color=color.goldenrod)
>>>>>>
>>>>> This sounds great; presumably it wouldn't be too hard to do, if very
>>>>> annoying (particularly because some of the plot methods only allow
>>>>> rgbcolor, others allow cmap options, etc.) - though what if I want red
>>>>> to stand for some other Python/Sage object?  And of course only
>>>>> English colors would be there, and what about gray/grey ...
>>>>>
>>>>> By the way, other readers of this thread please note:
>>>>>
>>>>> sage: plot(x^2, (x,0,1), color='red')
>>>>>
>>>>> works fine!
>>>>>
>>>>> - kcrisman
>>>>>
>>>> I particularly like the  rgbcolor notation. That's the only way I found
>>>> to have vector graphic environment (i.e inkscape) to match with
>>>> matplotlib or sage . On the other hand I usually use some kind of ...
>>>>
>>>> plot (x**2, (0,1), rgbcolor=(0.5,0.5,0) ) # dark green
>>>>
>>>> because I found the default green color (rgbcolor=(0,1,0)) looks too
>>>> brilliant with some beamers when you give a talk. Anyway, I tried with
>>>> rgbcolor='blue' ,'red','green','yellow','black','orange' and worked fine.
>>>
>>> Yes, I'm saying that in addition to being able to pass a tuple or
>>> string, we'd be able to pass a sage color object.
>>
>> That's a great idea, which is why I implemented it over a year ago :-)
>>
>> sage: C = Color('red')    # a Sage color object
>> sage: C
>> RGB color (1.0, 0.0, 0.0)
>> sage: C.html_color()
>> '#ff0000'
>> sage: plot(x^2, (x,0,1), color=C)
>>
>> I think the only strings allowed in the Color constructor are:
>>
>>     "red"   : (1.0,0.0,0.0),
>>     "orange": (1.0,.5,0.0),
>>     "yellow": (1.0,1.0,0.0),
>>     "green" : (0.0,1.0,0.0),
>>     "blue"  : (0.0,0.0,1.0),
>>     "purple": (.5,0.0,1.0),
>>     "white" : (1.0,1.0,1.0),
>>     "black" : (0.0,0.0,0.0),
>>     "grey"  : (.5,.5,.5)
>>
>> You can also use any html color strings.
>>
>> To give the functionality you want, you could add methods "lighter()"
>> and "darker()" to the existing color object.
>
>
> So how about:
>
> * predefining a bunch of colors in the global namespace (maybe just what
> is available in the current strings?)

I would say "-1", except Mathematica does that, and I'm for general
mathematica-style api compatibility.  So I'm +1 on that.

> * predefining a huge number of colors, but sticking them in the colors
> namespace

I don't care...

> * making some nicely matched color sets (color schemes, if you will).
> * make a generic mixing function (which takes the weighted average of
> self and other, according to a specifiable fraction)

That sounds useful.

> * make darker/lighter functions

That couldn't hurt.

> * adding together colors averages them

That makes sense.

> * a linear combination takes a weighted average (hmmm...have to think
> about how to do this one...maybe it'd make more sense to do a different
> average?)

Well if you do A + B + C, then Python will do "A+B" then (A+B)+C, so
the previous point determines this one.

> Here is what MMA does with colors:
> http://reference.wolfram.com/mathematica/guide/Colors.html
>
>
> Sounds like a great get-your-feet-wet student project...
>
> Jason
>
>
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to