Re: [Matplotlib-users] Possible to change MPL color scheme?

2012-07-22 Thread Benjamin Root
On Sat, Jul 21, 2012 at 1:21 PM, klo uo  wrote:

> Hi,
>
> I read previous mail about "colormaps" which reminded me to a question
> I had about MPL colors.
> Colors in MPL plots are dark, and pale, and not is some specific color
> theme but it's just pale dark.
> I thought that usually people make plots brighter (as more attractive ;) )
>
>
The default color cycle chosen is the same as many of the other popular
plotting tools, however, we provide the mechanism to define your own
cycles.  Admittedly, this isn't quite as good as I would like it, but that
is the rationale for the chosen default.



> If you can, have a look at this plot I just made, and same image with
> same named colors as set by CorelDraw for example:
> http://i.imgur.com/y29xD.png
>
> As you all probably know cyan is not cyan but teal, and green is with
> 50% green, and every color is not as expected, except red and blue.
> I don't know much about color systems and color space, so thought to
> ask why is it like this and if colors can be somehow differently
> defined at user end?
>
>
If you import matplotlib.colors, you can modify the "cnames" dictionary
like so:

import matplotlib.colors as mcolors
mcolors.cnames['cyan'] = mcolors.cnames['teal']
mcolors.cnames['green'] = '#00FF00'

As for using a CMYK system, the idea has been floated before and I
certainly would not be adverse to it.  But for backwards compatibility, we
would have to continue to support the RGB system.  There has been talk
about reworking the way colors are handled in matplotlib to use class
objects in order to unify the myriad of ways that colors can be specified
by the users.  Such a scheme would make the simultaneous use of CMYK and
RGB possible if they are both derived from a common base-class.

As for the assertion that HTML colors aren't used, that is incorrect.  The
named colors follow the HTML list.  Here is our list:

https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/colors.py#L62

and here is the html list:

http://html-color-codes.info/color-names/

Cheers!
Ben Root
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to Change Axis Tick Mark Labels

2012-07-22 Thread Benjamin Root
On Sat, Jul 21, 2012 at 10:27 PM, JonBL  wrote:

>
> I have a line plot where the x-axis values are numbers, with displayed tick
> mark values of 0, 100, 200 ... 500 - a total of 6 tick marks. These values
> represent the number of days since a certain date. I have a function which
> converts a number such as 100, to date string '23-Jun-11', which I want to
> display as the x-axis label instead of 100.
>
> Following the pypib example xaxis_props.py, and printing dir(label) for
> each
> label in the x-axis tick labels, I can see that a label object supports a
> number of methods that might assist in changing the text of tick mark
> labels. I was hoping to use the get_text() method to retrieve the label's
> text (eg, 100), transform this to a date string by my function, and then
> use
> the set_text() method to re-assign the displayed label.
>
> This approach does not work for me. The get_text() method returns a
> zero-length string (not None) for each label, and the set_text() method
> does
> not change the displayed tick mark values. But I can use the set_color()
> method to change the colour of displayed values as per example
> xaxis_props.py.
>
> Any suggestions on how to change the text of displayed x-axis tick marks?
>
> TIA,
>   Jon
>

Without example code, it would be difficult to determine what you are doing
incorrectly.  That being said, there is an easier solution.  If you know
the start date, do the following:

from datetime import datetime, timedelta
startdate = datetime.strptime(datestr, "%d-%m-%y)   # you need to look up
the format character for named months.

xdates = np.array([startdate + timedelta(days=i) for i in xrange(501)])
y = np.random.random(xdates.shape)

plt.plot(xdates, y)# This should work, but plot_date() definitely will
work.

Matplotlib recognizes the python datetime object and should format it for
you.  You can even control the formatting. See the following examples:
http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo_convert.html?highlight=datetime%20codex
http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo2.html?highlight=datetime%20codex
http://matplotlib.sourceforge.net/examples/api/date_demo.html?highlight=datetime%20codex
http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo1.html?highlight=datetime%20codex


I hope this helps!
Ben Root
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to Change Axis Tick Mark Labels

2012-07-22 Thread JonBL

Using FuncFormatter with my conversion procedure has solved my problem. I did
not use the Python datetime module to generate the tickmark labels as some
of your examples suggested. Instead, my conversion procedure pulls the
required formatted date string for an x-axis ticklabel date serial number
from an Oracle database which is the source of my plotted data.

This approach has also answered another question I had in mind - how do I
get the x= co-ordinate displayed at the bottom of the figure, to report the
formatted date rather than its serial number. 

I also had a response from Phil Elson who suggested using using
FuncFormatter as well. Many thanks to both of you for your timely responses
to my query.

Regards,
  Jon

Benjamin Root-2 wrote:
> 
> On Sat, Jul 21, 2012 at 10:27 PM, JonBL  wrote:
> 
>>
>> I have a line plot where the x-axis values are numbers, with displayed
>> tick
>> mark values of 0, 100, 200 ... 500 - a total of 6 tick marks. These
>> values
>> represent the number of days since a certain date. I have a function
>> which
>> converts a number such as 100, to date string '23-Jun-11', which I want
>> to
>> display as the x-axis label instead of 100.
>>
>> Following the pypib example xaxis_props.py, and printing dir(label) for
>> each
>> label in the x-axis tick labels, I can see that a label object supports a
>> number of methods that might assist in changing the text of tick mark
>> labels. I was hoping to use the get_text() method to retrieve the label's
>> text (eg, 100), transform this to a date string by my function, and then
>> use
>> the set_text() method to re-assign the displayed label.
>>
>> This approach does not work for me. The get_text() method returns a
>> zero-length string (not None) for each label, and the set_text() method
>> does
>> not change the displayed tick mark values. But I can use the set_color()
>> method to change the colour of displayed values as per example
>> xaxis_props.py.
>>
>> Any suggestions on how to change the text of displayed x-axis tick marks?
>>
>> TIA,
>>   Jon
>>
> 
> Without example code, it would be difficult to determine what you are
> doing
> incorrectly.  That being said, there is an easier solution.  If you know
> the start date, do the following:
> 
> from datetime import datetime, timedelta
> startdate = datetime.strptime(datestr, "%d-%m-%y)   # you need to look up
> the format character for named months.
> 
> xdates = np.array([startdate + timedelta(days=i) for i in xrange(501)])
> y = np.random.random(xdates.shape)
> 
> plt.plot(xdates, y)# This should work, but plot_date() definitely will
> work.
> 
> Matplotlib recognizes the python datetime object and should format it for
> you.  You can even control the formatting. See the following examples:
> http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo_convert.html?highlight=datetime%20codex
> http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo2.html?highlight=datetime%20codex
> http://matplotlib.sourceforge.net/examples/api/date_demo.html?highlight=datetime%20codex
> http://matplotlib.sourceforge.net/examples/pylab_examples/date_demo1.html?highlight=datetime%20codex
> 
> 
> I hope this helps!
> Ben Root
> 
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-Change-Axis-Tick-Mark-Labels-tp34195324p34197999.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Possible to change MPL color scheme?

2012-07-22 Thread klo uo
Thanks for your reply Ben,


On Sun, Jul 22, 2012 at 4:39 PM, Benjamin Root wrote:
> As for the assertion that HTML colors aren't used, that is incorrect.  The
> named colors follow the HTML list.  Here is our list:
>
> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/colors.py#L62
>
> and here is the html list:
>
> http://html-color-codes.info/color-names/

sure that's correct, I just meant about default defined colors with
abbrev color names, like 'y' (#BFBF00) in not 'yellow' (#00) etc.

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users