SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(16)
2
(31)
3
(17)
4
(18)
5
(7)
6
(5)
7
(16)
8
(9)
9
(19)
10
(18)
11
(17)
12
(7)
13
(6)
14
(15)
15
(16)
16
(15)
17
(19)
18
(27)
19
(10)
20
(5)
21
(5)
22
(19)
23
(7)
24
(11)
25
(19)
26
(1)
27
(36)
28
(37)
29
(28)
30
(36)



Showing results of 36

1 2 > >> (Page 1 of 2)
From: Peter B. <bu...@gm...> - 2009年09月27日 20:45:55
On Sun, Sep 27, 2009 at 9:31 PM, Jae-Joon Lee <lee...@gm...> wrote:
>> Some feedback: If plotting a line2D as discrete points rather than a
>> continuous line, you must use numpoints=2 for the legend picking to actually
>> occur on the points. The alpha blending doesn't work on the legend symbols
>> however.
>>
>
> I tried numpoints=1,2,3 but all worked for me. Can someone else confirm this?
I'm using windows and mpl 0.99.0:
numpoints=2 or 3 work
with numpoints=1 the pick does not occur on the symbol but where it
would be with numpoints=2
> The alpha for legend symbols does not work since, inside legend, the
> lines and symbols are drawn by different artists.
>
> Try something like below.
>
>
> legline.set_alpha(1.0)
> try:
> legline._legmarker.set_alpha(1.0)
> except AttributeError:
> pass
>
>
>
>> Is there any other way, I can show in the legend whether the points of the
>> series are visible or not ?
>>
>> I thought of changing the labels, but failed to get them to redraw.
>>
>
> Legend.get_texts() method returns the list of Text instances.
>
> http://matplotlib.sourceforge.net/api/artist_api.html?highlight=legend#matplotlib.legend.Legend.get_texts
>
> You may modify the returned Text instances.
>
> -JJ
>
works great.
>
>> # plots:
>> ax.plot(t, y1, 'ro', picker=5, label='lab1')
>> ax.plot(t, y2, 'bo', picker=5, label='lab2')
>>
>> # legend
>> leg = ax.legend(loc='upper left', numpoints=2, fancybox=True, shadow=True)
>> lines, labels = ax.get_legend_handles_labels()
>>
>> # Enable picking on the legend lines
>> leglines=leg.get_lines()
>> for legline in leglines: legline.set_picker(5)
From: Gökhan S. <gok...@gm...> - 2009年09月27日 20:32:51
On Sun, Sep 27, 2009 at 3:04 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Take a look at the examples/pylab_examples/demo_agg_filter.py
>
> Attached is a simple example that shows a line with gradient.
> However, the current image filter does not know about the data
> coordinate of the input image. Therefore, if you want to have your
> gradient stops at certain data values, you need to specify this in
> some manual way when you create the filter.
>
> Maybe the second approach that I mentioned might be more reasonable.
>
Agree. That first code is not an easy bite for me. I can tackle the second
one easily.
Thanks for the advice and pointers :)
>
> Regards,
>
> -JJ
>
>
>
>
> On Sun, Sep 27, 2009 at 2:25 AM, Gökhan Sever <gok...@gm...>
> wrote:
> >
> >
> > On Sat, Sep 26, 2009 at 10:16 PM, Jae-Joon Lee <lee...@gm...>
> wrote:
> >>
> >> The gradient, in general, is not supported by matplotlib yet.
> >> If you're only interested in raster format outputs (like png), I
> >> think you can use agg_filter functionality (but you need svn version
> >> of mpl).
> >
> > Could you give me a pointer on this where to look for the agg_filter,
> since
> > the search option doesn't yield any helpful results.
> >
> > I use the svn compiled matplotlib and docs.
> >
> > Thanks.
> >
> >
> >>
> >> Other wise, I guess your best bet is to divide you line into many
> >> segments and color them differently.
> >>
> >> -JJ
> >>
> >>
> >> On Sat, Sep 26, 2009 at 10:27 PM, Gökhan Sever <gok...@gm...>
> >> wrote:
> >> > Hello,
> >> >
> >> > Is it possible use a gradient color say from blue to red and/or
> >> > specifying
> >> > certain color threshold for a line plot (i.e I have air temperature
> >> > plotted
> >> > and I want to segment the color of the plot for temp > 0C red, and
> below
> >> > 0
> >> > make it blue.) Would be much nicer with gradient however I am content
> >> > for
> >> > the second option as well :)
> >> >
> >> > Thanks.
> >> >
> >> > --
> >> > Gökhan
> >> >
> >> >
> >> >
> ------------------------------------------------------------------------------
> >> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> >> > is the only developer event you need to attend this year. Jumpstart
> your
> >> > developing skills, take BlackBerry mobile applications to market and
> >> > stay
> >> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
> >> > now&#33;
> >> > http://p.sf.net/sfu/devconf
> >> > _______________________________________________
> >> > Matplotlib-users mailing list
> >> > Mat...@li...
> >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >> >
> >> >
> >
> >
> >
> > --
> > Gökhan
> >
>
-- 
Gökhan
From: Gökhan S. <gok...@gm...> - 2009年09月27日 20:18:47
When I run this as it is, and zoom once the top x-axis ticklabels disappear:
http://img2.imageshack.us/img2/5493/zoom1.png
After commenting these three lines:
#locator = MinuteLocator(interval=1)
#locator = SecondLocator(interval=30)
#par2.xaxis.set_major_locator(locator)
and running I get somewhat nice view after zooms:
http://img340.imageshack.us/img340/6632/zoom2.png
with a minute discrepancy; resulting with shifts on the top x-labels.
Any last thoughts?
On Sun, Sep 27, 2009 at 2:12 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Here it is.
>
> -JJ
>
> On Sun, Sep 27, 2009 at 3:09 PM, Gökhan Sever <gok...@gm...>
> wrote:
> > JJ,
> >
> > Could you please re-attach the code? Apparently, it has been forgotten on
> > your reply.
> >
> > Thanks.
> >
> > On Sun, Sep 27, 2009 at 1:50 PM, Jae-Joon Lee <lee...@gm...>
> wrote:
> >>
> >> Here is the modified version of your code that works for me.
> >>
> >> 1) If you change trans_aux, you also need to plot your data in an
> >> appropriate coordinate. Your original code did not work because you
> >> scaled the xaxis of the second axes (par) but you were still plotting
> >> the original data, i.e., "time" need to be scaled if you want to plot
> >> it on "par". The code below takes slightly different approach.
> >>
> >> 2) I fount that I was wrong with the factor of 3600. It needs to be
> >> 86400, i.e., a day in seconds. Also, The unit must be larger than 1.
> >> Again, please take a look how datetime unit works.
> >>
> >> Regards,
> >>
> >> -JJ
> >>
> >>
> >> import numpy as np
> >> import matplotlib.pyplot as plt
> >> import matplotlib.transforms as mtransforms
> >> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> >>
> >>
> >> # Prepare some random data and time for seconds-from-midnight (sfm)
> >> representation
> >> ydata1 = np.random.random(100) * 1000
> >> ydata2 = np.ones(100) / 2.
> >> time = np.arange(3550, 3650)
> >>
> >>
> >> fig = plt.figure()
> >> host = SubplotHost(fig, 111)
> >> fig.add_subplot(host)
> >>
> >> # This is the heart of the example. We have to scale the axes correctly.
> >> aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
> >> ydata1.max())
> >> par = host.twin(aux_trans)
> >>
> >> host.set_xlabel("Time [sfm]")
> >> host.set_ylabel("Random Data 1")
> >> par.set_ylabel("Random Data 2")
> >> par.axis["right"].label.set_visible(True)
> >>
> >> p1, = host.plot(time, ydata1)
> >> p2, = par.plot(time, ydata2)
> >>
> >> host.axis["left"].label.set_color(p1.get_color())
> >> par.axis["right"].label.set_color(p2.get_color())
> >>
> >> host.axis["bottom"].label.set_size(16)
> >> host.axis["left"].label.set_size(16)
> >> par.axis["right"].label.set_size(16)
> >>
> >> # Move the title little upwards so it won't overlap with the ticklabels
> >> title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
> >> title.set_position((0.5, 1.05))
> >>
> >> plt.show()
> >>
> >>
> >> On Sun, Sep 27, 2009 at 12:32 PM, Gökhan Sever <gok...@gm...>
> >> wrote:
> >> > Hello,
> >> >
> >> > As was suggested by Jae-Joon, I have simplified the code for easier
> >> > investigation and run. The aim of the script is to have time
> represented
> >> > on
> >> > both bottom and top x-axes, on the bottom in seconds-from-midnight
> >> > (SFM),
> >> > and the top should show as HH:MM:SS, while there is two different data
> >> > source being used for y-axes. The code could be seen here or from
> >> > http://code.google.com/p/ccnworks/source/browse/trunk/double_time.py
> >> >
> >> > Currently something wrong with the scaling, since the right y-axis
> data
> >> > is
> >> > missing on the plotting area. Also, sfm hasn't been converted to
> >> > HH:MM:SS.
> >> > adding this: par.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
> >> > doesn't remedy the situation as of yet.
> >> >
> >> > All comments are welcome.
> >> >
> >> > ### BEGIN CODE ###
> >> > #!/usr/bin/env python
> >> >
> >> > """
> >> >
> >> > Double time representation. Bottom x-axis shows time in
> >> > seconds-from-midnight
> >> > (sfm) fashion, whereas the top x-axis uses HH:MM:SS representation.
> >> >
> >> > Initially written by Gokhan Sever with helps from Jae-Joon Lee.
> >> >
> >> > Written: 2009年09月27日
> >> >
> >> > """
> >> >
> >> > import numpy as np
> >> > import matplotlib.pyplot as plt
> >> > import matplotlib.transforms as mtransforms
> >> > from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> >> >
> >> >
> >> > # Prepare some random data and time for seconds-from-midnight (sfm)
> >> > representation
> >> > ydata1 = np.random.random(100) * 1000
> >> > ydata2 = np.ones(100) / 2.
> >> > time = np.arange(3550, 3650)
> >> >
> >> >
> >> > fig = plt.figure()
> >> > host = SubplotHost(fig, 111)
> >> > fig.add_subplot(host)
> >> >
> >> > # This is the heart of the example. We have to scale the axes
> correctly.
> >> > aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
> >> > ydata1.max())
> >> > par = host.twin(aux_trans)
> >> >
> >> > host.set_xlabel("Time [sfm]")
> >> > host.set_ylabel("Random Data 1")
> >> > par.set_ylabel("Random Data 2")
> >> > par.axis["right"].label.set_visible(True)
> >> >
> >> > p1, = host.plot(time, ydata1)
> >> > p2, = par.plot(time, ydata2)
> >> >
> >> > host.axis["left"].label.set_color(p1.get_color())
> >> > par.axis["right"].label.set_color(p2.get_color())
> >> >
> >> > host.axis["bottom"].label.set_size(16)
> >> > host.axis["left"].label.set_size(16)
> >> > par.axis["right"].label.set_size(16)
> >> >
> >> > # Move the title little upwards so it won't overlap with the
> ticklabels
> >> > title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
> >> > title.set_position((0.5, 1.05))
> >> >
> >> > plt.show()
> >> > ### END CODE ###
> >> >
> >> >
> >> > --
> >> > Gökhan
> >> >
> >> >
> >> >
> ------------------------------------------------------------------------------
> >> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> >> > is the only developer event you need to attend this year. Jumpstart
> your
> >> > developing skills, take BlackBerry mobile applications to market and
> >> > stay
> >> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
> >> > now&#33;
> >> > http://p.sf.net/sfu/devconf
> >> > _______________________________________________
> >> > Matplotlib-users mailing list
> >> > Mat...@li...
> >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >> >
> >> >
> >
> >
> >
> > --
> > Gökhan
> >
>
-- 
Gökhan
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 20:04:36
Take a look at the examples/pylab_examples/demo_agg_filter.py
Attached is a simple example that shows a line with gradient.
However, the current image filter does not know about the data
coordinate of the input image. Therefore, if you want to have your
gradient stops at certain data values, you need to specify this in
some manual way when you create the filter.
Maybe the second approach that I mentioned might be more reasonable.
Regards,
-JJ
On Sun, Sep 27, 2009 at 2:25 AM, Gökhan Sever <gok...@gm...> wrote:
>
>
> On Sat, Sep 26, 2009 at 10:16 PM, Jae-Joon Lee <lee...@gm...> wrote:
>>
>> The gradient, in general, is not supported by matplotlib yet.
>> If you're only interested in raster format outputs (like png), I
>> think you can use agg_filter functionality (but you need svn version
>> of mpl).
>
> Could you give me a pointer on this where to look for the agg_filter, since
> the search option doesn't yield any helpful results.
>
> I use the svn compiled matplotlib and docs.
>
> Thanks.
>
>
>>
>> Other wise, I guess your best bet is to divide you line into many
>> segments and color them differently.
>>
>> -JJ
>>
>>
>> On Sat, Sep 26, 2009 at 10:27 PM, Gökhan Sever <gok...@gm...>
>> wrote:
>> > Hello,
>> >
>> > Is it possible use a gradient color say from blue to red and/or
>> > specifying
>> > certain color threshold for a line plot (i.e I have air temperature
>> > plotted
>> > and I want to segment the color of the plot for temp > 0C red, and below
>> > 0
>> > make it blue.) Would be much nicer with gradient however I am content
>> > for
>> > the second option as well :)
>> >
>> > Thanks.
>> >
>> > --
>> > Gökhan
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> > is the only developer event you need to attend this year. Jumpstart your
>> > developing skills, take BlackBerry mobile applications to market and
>> > stay
>> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
>> > now&#33;
>> > http://p.sf.net/sfu/devconf
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Mat...@li...
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> >
>> >
>
>
>
> --
> Gökhan
>
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 19:31:47
On Sun, Sep 27, 2009 at 10:02 AM, butterw <bu...@gm...> wrote:
>
> Hi,
>
> thank you for clearing that up.
>
>
> Some feedback: If plotting a line2D as discrete points rather than a
> continuous line, you must use numpoints=2 for the legend picking to actually
> occur on the points. The alpha blending doesn't work on the legend symbols
> however.
>
I tried numpoints=1,2,3 but all worked for me. Can someone else confirm this?
The alpha for legend symbols does not work since, inside legend, the
lines and symbols are drawn by different artists.
Try something like below.
 legline.set_alpha(1.0)
 try:
 legline._legmarker.set_alpha(1.0)
 except AttributeError:
 pass
> Is there any other way, I can show in the legend whether the points of the
> series are visible or not ?
>
> I thought of changing the labels, but failed to get them to redraw.
>
Legend.get_texts() method returns the list of Text instances.
http://matplotlib.sourceforge.net/api/artist_api.html?highlight=legend#matplotlib.legend.Legend.get_texts
You may modify the returned Text instances.
-JJ
> # plots:
> ax.plot(t, y1, 'ro', picker=5, label='lab1')
> ax.plot(t, y2, 'bo', picker=5, label='lab2')
>
> # legend
> leg = ax.legend(loc='upper left', numpoints=2, fancybox=True, shadow=True)
> lines, labels = ax.get_legend_handles_labels()
>
> # Enable picking on the legend lines
> leglines=leg.get_lines()
> for legline in leglines: legline.set_picker(5)
>
>
>
>
>
> Jae-Joon Lee wrote:
>>
>> On Wed, Sep 23, 2009 at 3:27 PM, butterw <bu...@gm...> wrote:
>>>
>>> Hi,
>>>
>>> pickers work great to make matplotlib plots more interactive/general user
>>> friendly.
>>>
>>> On the subject of the legend_picker.py example, I was wondering if it was
>>> possible to combine both a legend picker and a line picker in the same
>>> plot.
>>> From what I gather they will both use the same onpick event callback.
>>>
>>> So my question is : How do I discriminate between a pick on the legend
>>> from
>>> a pick on a line ? The event.artist is a line2D in both cases.
>>
>> As demonstrated in the above example, leg.get_lines() gives you the
>> list of lines inside the legend. The list of original lines is kept in
>> ax.lines.
>> So, you can check in which list the given artist is.
>>
>> Regards,
>>
>> -JJ
>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> John Hunter-4 wrote:
>>>>
>>>> On Mon, Aug 3, 2009 at 11:38 PM, Gökhan Sever<gok...@gm...>
>>>> wrote:
>>>>> Hello,
>>>>>
>>>>> I was wondering if it is possible to hide some data on figures using a
>>>>> say
>>>>> right click option to any of the legend entry and make it temporarily
>>>>> hidden/visible to better analyse the rest of the data?
>>>>>
>>>>> Check this screenshot for example:
>>>>>
>>>>> http://img25.imageshack.us/img25/9427/datahiding.png
>>>>>
>>>>> The red data clutters the rest of the figure, and I would like to be
>>>>> able
>>>>> to
>>>>> hide it temporarily so that I can investigate the other two relations
>>>>> more
>>>>> easily.
>>>>>
>>>>> Any ideas? or alternative solutions?
>>>>
>>>> It's a nice idea, and should be doable with the pick interface we have
>>>> for all mpl artists. Unfortunately, there were a few problems in the
>>>> legend implementation which blocked the pick events from hitting the
>>>> proxy lines they contained. I just made a few changes to mpl svn HEAD
>>>> to support this, and added a new example.
>>>>
>>>>  examples/event_handling/legend_picking.py
>>>>
>>>> which I'll include below.  JJ could you review the changes to
>>>> legend.py?
>>>>
>>>> Instructions for checking out svn are at::
>>>>
>>>>
>>>> http://matplotlib.sourceforge.net/faq/installing_faq.html#install-from-svn
>>>>
>>>> Here is the example:
>>>>
>>>> """
>>>> Enable picking on the legend to toggle the legended line on and off
>>>> """
>>>> import numpy as np
>>>> import matplotlib.pyplot as plt
>>>>
>>>> t = np.arange(0.0, 0.2, 0.1)
>>>> y1 = 2*np.sin(2*np.pi*t)
>>>> y2 = 4*np.sin(2*np.pi*2*t)
>>>>
>>>> fig = plt.figure()
>>>> ax = fig.add_subplot(111)
>>>>
>>>> line1, = ax.plot(t, y1, lw=2, color='red', label='1 hz')
>>>> line2, = ax.plot(t, y2, lw=2, color='blue', label='2 hz')
>>>>
>>>> leg = ax.legend(loc='upper left', fancybox=True, shadow=True)
>>>> leg.get_frame().set_alpha(0.4)
>>>>
>>>>
>>>> lines = [line1, line2]
>>>> lined = dict()
>>>> for legline, realine in zip(leg.get_lines(), lines):
>>>>   legline.set_picker(5) # 5 pts tolerance
>>>>   lined[legline] = realine
>>>>
>>>> def onpick(event):
>>>>   legline = event.artist
>>>>   realline = lined[legline]
>>>>   vis = realline.get_visible()
>>>>   realline.set_visible(not vis)
>>>>   fig.canvas.draw()
>>>>
>>>> fig.canvas.mpl_connect('pick_event', onpick)
>>>>
>>>> plt.show()
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>>> 30-Day
>>>> trial. Simplify your report design, integration and deployment - and
>>>> focus
>>>> on
>>>> what you do best, core application coding. Discover what's new with
>>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> Mat...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Hiding-data-via-legend-tp24802219p25531267.html
>>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>>> is the only developer event you need to attend this year. Jumpstart your
>>> developing skills, take BlackBerry mobile applications to market and stay
>>> ahead of the curve. Join us from November 9&#45;12, 2009. Register
>>> now&#33;
>>> http://p.sf.net/sfu/devconf
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register
>> now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Hiding-data-via-legend-tp24802219p25633860.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 19:12:43
Attachments: asdsd.py
Here it is.
-JJ
On Sun, Sep 27, 2009 at 3:09 PM, Gökhan Sever <gok...@gm...> wrote:
> JJ,
>
> Could you please re-attach the code? Apparently, it has been forgotten on
> your reply.
>
> Thanks.
>
> On Sun, Sep 27, 2009 at 1:50 PM, Jae-Joon Lee <lee...@gm...> wrote:
>>
>> Here is the modified version of your code that works for me.
>>
>> 1) If you change trans_aux, you also need to plot your data in an
>> appropriate coordinate. Your original code did not work because you
>> scaled the xaxis of the second axes (par) but you were still plotting
>> the original data, i.e., "time" need to be scaled if you want to plot
>> it on "par". The code below takes slightly different approach.
>>
>> 2) I fount that I was wrong with the factor of 3600. It needs to be
>> 86400, i.e., a day in seconds. Also, The unit must be larger than 1.
>> Again, please take a look how datetime unit works.
>>
>> Regards,
>>
>> -JJ
>>
>>
>> import numpy as np
>> import matplotlib.pyplot as plt
>> import matplotlib.transforms as mtransforms
>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>>
>>
>> # Prepare some random data and time for seconds-from-midnight (sfm)
>> representation
>> ydata1 = np.random.random(100) * 1000
>> ydata2 = np.ones(100) / 2.
>> time = np.arange(3550, 3650)
>>
>>
>> fig = plt.figure()
>> host = SubplotHost(fig, 111)
>> fig.add_subplot(host)
>>
>> # This is the heart of the example. We have to scale the axes correctly.
>> aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
>> ydata1.max())
>> par = host.twin(aux_trans)
>>
>> host.set_xlabel("Time [sfm]")
>> host.set_ylabel("Random Data 1")
>> par.set_ylabel("Random Data 2")
>> par.axis["right"].label.set_visible(True)
>>
>> p1, = host.plot(time, ydata1)
>> p2, = par.plot(time, ydata2)
>>
>> host.axis["left"].label.set_color(p1.get_color())
>> par.axis["right"].label.set_color(p2.get_color())
>>
>> host.axis["bottom"].label.set_size(16)
>> host.axis["left"].label.set_size(16)
>> par.axis["right"].label.set_size(16)
>>
>> # Move the title little upwards so it won't overlap with the ticklabels
>> title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
>> title.set_position((0.5, 1.05))
>>
>> plt.show()
>>
>>
>> On Sun, Sep 27, 2009 at 12:32 PM, Gökhan Sever <gok...@gm...>
>> wrote:
>> > Hello,
>> >
>> > As was suggested by Jae-Joon, I have simplified the code for easier
>> > investigation and run. The aim of the script is to have time represented
>> > on
>> > both bottom and top x-axes, on the bottom in seconds-from-midnight
>> > (SFM),
>> > and the top should show as HH:MM:SS, while there is two different data
>> > source being used for y-axes. The code could be seen here or from
>> > http://code.google.com/p/ccnworks/source/browse/trunk/double_time.py
>> >
>> > Currently something wrong with the scaling, since the right y-axis data
>> > is
>> > missing on the plotting area. Also, sfm hasn't been converted to
>> > HH:MM:SS.
>> > adding this: par.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
>> > doesn't remedy the situation as of yet.
>> >
>> > All comments are welcome.
>> >
>> > ### BEGIN CODE ###
>> > #!/usr/bin/env python
>> >
>> > """
>> >
>> > Double time representation. Bottom x-axis shows time in
>> > seconds-from-midnight
>> > (sfm) fashion, whereas the top x-axis uses HH:MM:SS representation.
>> >
>> > Initially written by Gokhan Sever with helps from Jae-Joon Lee.
>> >
>> > Written: 2009年09月27日
>> >
>> > """
>> >
>> > import numpy as np
>> > import matplotlib.pyplot as plt
>> > import matplotlib.transforms as mtransforms
>> > from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>> >
>> >
>> > # Prepare some random data and time for seconds-from-midnight (sfm)
>> > representation
>> > ydata1 = np.random.random(100) * 1000
>> > ydata2 = np.ones(100) / 2.
>> > time = np.arange(3550, 3650)
>> >
>> >
>> > fig = plt.figure()
>> > host = SubplotHost(fig, 111)
>> > fig.add_subplot(host)
>> >
>> > # This is the heart of the example. We have to scale the axes correctly.
>> > aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
>> > ydata1.max())
>> > par = host.twin(aux_trans)
>> >
>> > host.set_xlabel("Time [sfm]")
>> > host.set_ylabel("Random Data 1")
>> > par.set_ylabel("Random Data 2")
>> > par.axis["right"].label.set_visible(True)
>> >
>> > p1, = host.plot(time, ydata1)
>> > p2, = par.plot(time, ydata2)
>> >
>> > host.axis["left"].label.set_color(p1.get_color())
>> > par.axis["right"].label.set_color(p2.get_color())
>> >
>> > host.axis["bottom"].label.set_size(16)
>> > host.axis["left"].label.set_size(16)
>> > par.axis["right"].label.set_size(16)
>> >
>> > # Move the title little upwards so it won't overlap with the ticklabels
>> > title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
>> > title.set_position((0.5, 1.05))
>> >
>> > plt.show()
>> > ### END CODE ###
>> >
>> >
>> > --
>> > Gökhan
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> > is the only developer event you need to attend this year. Jumpstart your
>> > developing skills, take BlackBerry mobile applications to market and
>> > stay
>> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
>> > now&#33;
>> > http://p.sf.net/sfu/devconf
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Mat...@li...
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> >
>> >
>
>
>
> --
> Gökhan
>
From: Gökhan S. <gok...@gm...> - 2009年09月27日 19:09:22
JJ,
Could you please re-attach the code? Apparently, it has been forgotten on
your reply.
Thanks.
On Sun, Sep 27, 2009 at 1:50 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Here is the modified version of your code that works for me.
>
> 1) If you change trans_aux, you also need to plot your data in an
> appropriate coordinate. Your original code did not work because you
> scaled the xaxis of the second axes (par) but you were still plotting
> the original data, i.e., "time" need to be scaled if you want to plot
> it on "par". The code below takes slightly different approach.
>
> 2) I fount that I was wrong with the factor of 3600. It needs to be
> 86400, i.e., a day in seconds. Also, The unit must be larger than 1.
> Again, please take a look how datetime unit works.
>
> Regards,
>
> -JJ
>
>
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.transforms as mtransforms
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>
>
> # Prepare some random data and time for seconds-from-midnight (sfm)
> representation
> ydata1 = np.random.random(100) * 1000
> ydata2 = np.ones(100) / 2.
> time = np.arange(3550, 3650)
>
>
> fig = plt.figure()
> host = SubplotHost(fig, 111)
> fig.add_subplot(host)
>
> # This is the heart of the example. We have to scale the axes correctly.
> aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
> ydata1.max())
> par = host.twin(aux_trans)
>
> host.set_xlabel("Time [sfm]")
> host.set_ylabel("Random Data 1")
> par.set_ylabel("Random Data 2")
> par.axis["right"].label.set_visible(True)
>
> p1, = host.plot(time, ydata1)
> p2, = par.plot(time, ydata2)
>
> host.axis["left"].label.set_color(p1.get_color())
> par.axis["right"].label.set_color(p2.get_color())
>
> host.axis["bottom"].label.set_size(16)
> host.axis["left"].label.set_size(16)
> par.axis["right"].label.set_size(16)
>
> # Move the title little upwards so it won't overlap with the ticklabels
> title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
> title.set_position((0.5, 1.05))
>
> plt.show()
>
>
> On Sun, Sep 27, 2009 at 12:32 PM, Gökhan Sever <gok...@gm...>
> wrote:
> > Hello,
> >
> > As was suggested by Jae-Joon, I have simplified the code for easier
> > investigation and run. The aim of the script is to have time represented
> on
> > both bottom and top x-axes, on the bottom in seconds-from-midnight (SFM),
> > and the top should show as HH:MM:SS, while there is two different data
> > source being used for y-axes. The code could be seen here or from
> > http://code.google.com/p/ccnworks/source/browse/trunk/double_time.py
> >
> > Currently something wrong with the scaling, since the right y-axis data
> is
> > missing on the plotting area. Also, sfm hasn't been converted to
> HH:MM:SS.
> > adding this: par.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
> > doesn't remedy the situation as of yet.
> >
> > All comments are welcome.
> >
> > ### BEGIN CODE ###
> > #!/usr/bin/env python
> >
> > """
> >
> > Double time representation. Bottom x-axis shows time in
> > seconds-from-midnight
> > (sfm) fashion, whereas the top x-axis uses HH:MM:SS representation.
> >
> > Initially written by Gokhan Sever with helps from Jae-Joon Lee.
> >
> > Written: 2009年09月27日
> >
> > """
> >
> > import numpy as np
> > import matplotlib.pyplot as plt
> > import matplotlib.transforms as mtransforms
> > from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> >
> >
> > # Prepare some random data and time for seconds-from-midnight (sfm)
> > representation
> > ydata1 = np.random.random(100) * 1000
> > ydata2 = np.ones(100) / 2.
> > time = np.arange(3550, 3650)
> >
> >
> > fig = plt.figure()
> > host = SubplotHost(fig, 111)
> > fig.add_subplot(host)
> >
> > # This is the heart of the example. We have to scale the axes correctly.
> > aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
> > ydata1.max())
> > par = host.twin(aux_trans)
> >
> > host.set_xlabel("Time [sfm]")
> > host.set_ylabel("Random Data 1")
> > par.set_ylabel("Random Data 2")
> > par.axis["right"].label.set_visible(True)
> >
> > p1, = host.plot(time, ydata1)
> > p2, = par.plot(time, ydata2)
> >
> > host.axis["left"].label.set_color(p1.get_color())
> > par.axis["right"].label.set_color(p2.get_color())
> >
> > host.axis["bottom"].label.set_size(16)
> > host.axis["left"].label.set_size(16)
> > par.axis["right"].label.set_size(16)
> >
> > # Move the title little upwards so it won't overlap with the ticklabels
> > title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
> > title.set_position((0.5, 1.05))
> >
> > plt.show()
> > ### END CODE ###
> >
> >
> > --
> > Gökhan
> >
> >
> ------------------------------------------------------------------------------
> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> > is the only developer event you need to attend this year. Jumpstart your
> > developing skills, take BlackBerry mobile applications to market and stay
> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
> now&#33;
> > http://p.sf.net/sfu/devconf
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
-- 
Gökhan
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 19:07:05
I hope my answer in the other thread clears your problem.
One note, I found that some grid lines are missing at first run. This
can be fixed by using "host.xaxis.get_major_ticks()" instead of
"host.xaxis.majorTicks" (same for yaxis).
-JJ
On Sun, Sep 27, 2009 at 2:22 AM, Gökhan Sever <gok...@gm...> wrote:
>
>
> On Sat, Sep 26, 2009 at 11:14 PM, Jae-Joon Lee <lee...@gm...> wrote:
>>
>> On Sat, Sep 26, 2009 at 11:10 PM, Gökhan Sever <gok...@gm...>
>> wrote:
>> > To run the code, you have to get nasafile.py and add this into your
>> > PYTHONPATH, later get dccn_plot.py and
>> > 09_03_26_11_36_15.dmtccnc.combined.raw file. nasafile.py has the
>> > NasaFile
>> > class to read this ascii file.
>> >
>> > run as ./dccn_plot.py 09_03_26_11_36_15.dmtccnc.combined.raw
>> >
>>
>> Please note that your entire application is hardly a "small, complete
>> example".
>> While I did download your code from the svn and ran it, but
>> understand that it makes the job difficult and reduces your chance of
>> getting help from the developers (or other users).
>>
>
> I know it is getting complex even for myself. Lots of data source and trying
> to make a general reading routine is somewhat lowering the readability. You
> should have seen this same code without classes in action. That NasaFile
> class has helped me alot actually, but the extra functionality also adds
> lots of lines of code there, too. Thinking of moving this to a GUI.
> Nevertheless for the time being I am talking in a more speculative way.
>
>
>>
>> > I have changed the code as you suggested. Here is the result:
>> > http://img44.imageshack.us/img44/1075/newsso.png
>> >
>> > Two things I notice, right y-axis label is gone, and latter the top
>> > x-axis
>> > nicely added there but it a replicate of bottom x-axis. Doing this:
>>
>> For the diappearing label,
>> unfortunately, the axes_grid toolkits has slightly different behavior
>> from mainline mpl.
>>
>>
>> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#id5
>>
>>
>> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html
>>
>> Adding
>>
>> pary.axis["right"].label.set_visible(True)
>>
>> in your code will work.
>
> Thanks, this worked.
>
>>
>> At second thought, this might be a bug in the axes_grid toolkit.
>>
>> For your second point.
>> There is a reason that I used a factor 3600 in my first example.
>>
>> aux_trans = mtransforms.Affine2D().scale(3600., y_max) # transform
>> from ax2 to ax1
>
> Added this line to the code:
>
> aux_trans = mtransforms.Affine2D().translate(0., 0.).\
>       scale(3600, dccn.data['dccnConSTP'].max())
>
> See how the output looks like :
> http://img18.imageshack.us/img18/5056/newss2.png
>
> As you might see, the pary plotting disappears, when I use this scaling
> which seemingly correct scaling for my case. It remedies the top axis
> properly. They are correct equivalences of second-from-midnight
> representation of time, i.e 45000 --> 12:30:00 (12.5)
>
> When I play a little bit more in IPython (Still experiment, not in a
> production stage :)) when the figure is up:
>
> pary.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
>
> Then it turns wrong: http://img3.imageshack.us/img3/4707/newss3.png
> Either my understanding, or somethings internally in formatting code.
>
> So close, these things are not easy to figure out. And to me these are
> beyond advanced matplotlib functionality. I will put a more simplified
> sample code once I figure out this.
>
> Thank you again.
>
>
>
>
>
>
>>
>> You need to try to understand the units for date-time display and then
>> figure out the correct transform for your need.
>> If you try 3600, the unit will show as hours. But you may need some
>> more work to make it fit your need.
>>
>> -JJ
>>
>>
>> >
>> > from matplotlib.dates import DateFormatter, HourLocator
>> > locator  = HourLocator()
>> > pary.xaxis.set_major_locator(locator)
>> > formatter = DateFormatter(r'$%H^h
>> > )
>> > ax2.xaxis.set_major_formatter(formatter)
>> >
>> > results with my IPython session crashed:
>> >
>> > RuntimeError: Locator attempting to generate 216001 ticks from 41000.0
>> > to
>> > 50000.0: exceeds Locator.MAXTICKS
>> >
>> >
>> > I want to be able see in this fashion:
>> >
>> > I[3]: current_axis = gca()
>> > I[4]: current_axis.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
>> >
>> > but this returns the bottom x-axis and changes them to all 00:00:00.
>
>
>
> --
> Gökhan
>
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 18:58:27
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.bar
The second argument is the heights of the bars, not the top coordinate.
-JJ
On Sun, Sep 27, 2009 at 11:29 AM, per freem <per...@gm...> wrote:
> hi all,
>
> i am trying to make a simple stacked bar graphs (just two layers) and
> am getting some strange results. i have the following code:
>
> import numpy as np
> import matplotlib.pyplot as plt
> ind = np.arange(3)
> width = 0.35
> plt.bar(ind, [5128307, 4305252, 4817425], width, align='center', color='r')
> plt.bar(ind, [5969352, 5011032, 5590754], width, align='center',
> bottom=[5128307, 4305252, 4817425], color='k')
>
> i want it to be so that the bar graphs with values [5128307, 4305252,
> 4817425] appear in red "below" the taller bar graphs with values
> [5969352, 5011032, 5590754]. when i try to plot this, i get a very
> strange y-axis, formatted on a 1e7 scales, and the values appear
> wrong.
>
> if i modify my plot to simply be:
>
> ind = np.arange(3)
> width = 0.35
> plt.bar(ind, [5969352, 5011032, 5590754], width, align='center', color='k')
>
> then the y-axis appears correctly, with ylim set to 6 million. how can
> i get the graph to look just like this, except have the stacked
> smaller bar graphs appear in red?
>
> any help on this would be greatly appreciated.
>
> thanks.
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 18:50:52
Here is the modified version of your code that works for me.
1) If you change trans_aux, you also need to plot your data in an
appropriate coordinate. Your original code did not work because you
scaled the xaxis of the second axes (par) but you were still plotting
the original data, i.e., "time" need to be scaled if you want to plot
it on "par". The code below takes slightly different approach.
2) I fount that I was wrong with the factor of 3600. It needs to be
86400, i.e., a day in seconds. Also, The unit must be larger than 1.
Again, please take a look how datetime unit works.
Regards,
-JJ
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
# Prepare some random data and time for seconds-from-midnight (sfm)
representation
ydata1 = np.random.random(100) * 1000
ydata2 = np.ones(100) / 2.
time = np.arange(3550, 3650)
fig = plt.figure()
host = SubplotHost(fig, 111)
fig.add_subplot(host)
# This is the heart of the example. We have to scale the axes correctly.
aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600, ydata1.max())
par = host.twin(aux_trans)
host.set_xlabel("Time [sfm]")
host.set_ylabel("Random Data 1")
par.set_ylabel("Random Data 2")
par.axis["right"].label.set_visible(True)
p1, = host.plot(time, ydata1)
p2, = par.plot(time, ydata2)
host.axis["left"].label.set_color(p1.get_color())
par.axis["right"].label.set_color(p2.get_color())
host.axis["bottom"].label.set_size(16)
host.axis["left"].label.set_size(16)
par.axis["right"].label.set_size(16)
# Move the title little upwards so it won't overlap with the ticklabels
title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
title.set_position((0.5, 1.05))
plt.show()
On Sun, Sep 27, 2009 at 12:32 PM, Gökhan Sever <gok...@gm...> wrote:
> Hello,
>
> As was suggested by Jae-Joon, I have simplified the code for easier
> investigation and run. The aim of the script is to have time represented on
> both bottom and top x-axes, on the bottom in seconds-from-midnight (SFM),
> and the top should show as HH:MM:SS, while there is two different data
> source being used for y-axes. The code could be seen here or from
> http://code.google.com/p/ccnworks/source/browse/trunk/double_time.py
>
> Currently something wrong with the scaling, since the right y-axis data is
> missing on the plotting area. Also, sfm hasn't been converted to HH:MM:SS.
> adding this: par.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
> doesn't remedy the situation as of yet.
>
> All comments are welcome.
>
> ### BEGIN CODE ###
> #!/usr/bin/env python
>
> """
>
> Double time representation. Bottom x-axis shows time in
> seconds-from-midnight
> (sfm) fashion, whereas the top x-axis uses HH:MM:SS representation.
>
> Initially written by Gokhan Sever with helps from Jae-Joon Lee.
>
> Written: 2009年09月27日
>
> """
>
> import numpy as np
> import matplotlib.pyplot as plt
> import matplotlib.transforms as mtransforms
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>
>
> # Prepare some random data and time for seconds-from-midnight (sfm)
> representation
> ydata1 = np.random.random(100) * 1000
> ydata2 = np.ones(100) / 2.
> time = np.arange(3550, 3650)
>
>
> fig = plt.figure()
> host = SubplotHost(fig, 111)
> fig.add_subplot(host)
>
> # This is the heart of the example. We have to scale the axes correctly.
> aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
> ydata1.max())
> par = host.twin(aux_trans)
>
> host.set_xlabel("Time [sfm]")
> host.set_ylabel("Random Data 1")
> par.set_ylabel("Random Data 2")
> par.axis["right"].label.set_visible(True)
>
> p1, = host.plot(time, ydata1)
> p2, = par.plot(time, ydata2)
>
> host.axis["left"].label.set_color(p1.get_color())
> par.axis["right"].label.set_color(p2.get_color())
>
> host.axis["bottom"].label.set_size(16)
> host.axis["left"].label.set_size(16)
> par.axis["right"].label.set_size(16)
>
> # Move the title little upwards so it won't overlap with the ticklabels
> title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
> title.set_position((0.5, 1.05))
>
> plt.show()
> ### END CODE ###
>
>
> --
> Gökhan
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Phillip M. F. <pfe...@ve...> - 2009年09月27日 18:17:09
Thanks very much for the help. I have made some progress, but am still 
having difficulties.
I wrote a function called make_solid_cmap (see test program below) that 
takes a colormap name, a list of thresholds, and a list of colors as 
inputs, and produces and registers a solid-color colormap. In the test 
program, I attempt to create a solid-color colormap containing the 
colors red, yellow, green, and blue.
Problem #1: When I use this colormap (in another piece of code that's 
not shown), the result is a series of shades of gray.
Problem #2: The test program attempts to retrieve and display all 
registered colormaps, but the one that I created in the test program 
does not appear in the figure.
Phillip
### Start of code ###
from matplotlib import *
import matplotlib.pyplot as pyplot
from numpy import linspace, outer
from pylab import *
# Section 1: Define function for generating solid-color colormaps.
def make_solid_cmap(cmap_name, colors, thresholds=None):
 """Use list of colors (names or RGB tuples) and list of thresholds to 
create
 a solid-color colormap."""
 # name_to_rgb converts a color name (string) to an RGB 3-tuple:
 from webcolors import name_to_rgb
 print 'len(colors)= ', len(colors)
 if not isinstance(colors,list) or len(colors)<2:
 raise Exception, 'colors must be a list of length 2 or greater.'
 if thresholds is None:
 # Assign default set of uniformly-spaced thresholds:
 thresholds= linspace(0.0, 1.0, len(colors)+1)[1:-1]
 else:
 if not isinstance(thresholds,list):
 raise Exception, 'thresholds must be a list.'
 print 'thresholds= ', thresholds
 if not isinstance(cmap_name,str) or len(cmap_name)==0:
 raise Exception, 'cmap_name must be a non-null string.'
 if len(colors)!=len(thresholds)+1:
 raise Exception, 'The list of colors must be one longer than the 
list ' \
 'of thresholds.'
 for i in range(len(colors)):
 # If the ith color is specified via a name, replace the string 
with an RGB
 # 3-tuple:
 if isinstance(colors[i],str): colors[i]= name_to_rgb(colors[i])
 # If all three components of the tuple are ints, normalize by 256. to
 # obtain floats in [0,1):
 if isinstance(colors[i][0],int) and isinstance(colors[i][1],int) and \
 isinstance(colors[i][2],int):
 colors[i]= (colors[i][0]/256., colors[i][1]/256., 
colors[i][2]/256.)
 # For each of the three RGB components, create initial empty list:
 red_list= green_list= blue_list= []
 # Each list will consist of a series of 3-tuples. The components of each
 # 3-tuple are the threshold value, y0, and y1. The threshold in the 
first
 # tuple is always zero, and the second component of the first tuple is
 # ignored, so we can set it to zero as well.
 red_list .append( (0.0 , 0.0, colors[0][0] ) )
 green_list .append( (0.0 , 0.0, colors[0][1] ) )
 blue_list .append( (0.0 , 0.0, colors[0][2] ) )
 for i in range(len(thresholds)):
 red_list .append( (thresholds[i], colors[i][0], colors[i+1][0]) )
 green_list.append( (thresholds[i], colors[i][1], colors[i+1][1]) )
 blue_list .append( (thresholds[i], colors[i][2], colors[i+1][2]) )
 red_list .append( (1.0 , colors[-1][0], 0.0 ) )
 green_list .append( (1.0 , colors[-1][1], 0.0 ) )
 blue_list .append( (1.0 , colors[-1][2], 0.0 ) )
 cmap= matplotlib.colors.LinearSegmentedColormap(cmap_name, {
 'red' : tuple(red_list),
 'green': tuple(green_list),
 'blue' : tuple(blue_list)
 } )
 pyplot.register_cmap(cmap=cmap)
# Section 2: Create and register a solid-color colormap containing red, 
yellow,
# green, and blue (in that order):
make_solid_cmap('rygb', ['red','yellow','green','blue'])
# Section 3: Display all registered colormaps.
close(1)
rc('text', usetex=False)
a=outer(arange(0,1,0.01),ones(10))
fig= pyplot.figure(figsize=(13,7), dpi=120, facecolor=[1,1,1])
subplots_adjust(top=0.8,bottom=0.05,left=0.01,right=0.99)
maps=[m for m in cm.datad.keys() if not m.endswith("_r")]
maps.sort()
l=len(maps)+1
i=1
for m in maps:
 print m
 subplot(1,l,i)
 axis("off")
 imshow(a,aspect='auto',cmap=get_cmap(m),origin="lower")
 title(m,rotation=90,fontsize=18)
 i=i+1
show()
Eric Firing wrote:
> Dr. Phillip M. Feldman wrote:
>> I'd like to be able to create and use a custom colormap. I'm 
>> creating the
>> colormap via
>> the following statement:
>>
>> matplotlib.colors.ListedColormap([(0,0,0),(0.6,0,0),(0,0.6,0),(0.6,0.6,0)], 
>>
>> name='Earth')
>
> Assign it to a variable, like
>
> earth_cmap = matplotlib.colors.ListedColormap(
> [(0,0,0),(0.6,0,0),(0,0.6,0),(0.6,0.6,0)],
> name='Earth')
>
> and then use cmap=earth_cmap as your kwarg specification.
>
> The ability to register user-generated cmaps so that they can be 
> retrieved via get_cmap is very new, and not present in 0.98.5. It is 
> in the latest release (0.99.1), though. You would need to use the 
> register_cmap function.
>
> Eric
>
>>
>> The above statement appears to work, but when I attempt to use this
>> colormap, I
>> get the error shown below. Any suggestions will be appreciated.
>>
>> AssertionError Traceback (most recent call 
>> last)
>>
>> art.py in <module>()
>> 253
>> 254 # Plot z as image using specified color map:
>> --> 255 pyplot.imshow(z, origin='lower', 
>> cmap=get_cmap(map_names[n_map-1]),
>> 256 extent=[x.min(),x.max(),y.min(),y.max()])
>> 257
>>
>> C:\Program
>> Files\Python25\lib\site-packages\matplotlib-0.98.5.2n2-py2.5-win32.egg\matplotlib\cm.pyc 
>>
>> in get_cmap(name, lut)
>> 19 if lut is None: lut = mpl.rcParams['image.lut']
>> 20
>> ---> 21 assert(name in datad.keys())
>> 22 return colors.LinearSegmentedColormap(name, datad[name], 
>> lut)
>> 23
>>
>> AssertionError:
>
>
From: Gökhan S. <gok...@gm...> - 2009年09月27日 16:32:51
Hello,
As was suggested by Jae-Joon, I have simplified the code for easier
investigation and run. The aim of the script is to have time represented on
both bottom and top x-axes, on the bottom in seconds-from-midnight (SFM),
and the top should show as HH:MM:SS, while there is two different data
source being used for y-axes. The code could be seen here or from
http://code.google.com/p/ccnworks/source/browse/trunk/double_time.py
Currently something wrong with the scaling, since the right y-axis data is
missing on the plotting area. Also, sfm hasn't been converted to HH:MM:SS.
adding this: par.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
doesn't remedy the situation as of yet.
All comments are welcome.
### BEGIN CODE ###
#!/usr/bin/env python
"""
Double time representation. Bottom x-axis shows time in
seconds-from-midnight
(sfm) fashion, whereas the top x-axis uses HH:MM:SS representation.
Initially written by Gokhan Sever with helps from Jae-Joon Lee.
Written: 2009年09月27日
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
# Prepare some random data and time for seconds-from-midnight (sfm)
representation
ydata1 = np.random.random(100) * 1000
ydata2 = np.ones(100) / 2.
time = np.arange(3550, 3650)
fig = plt.figure()
host = SubplotHost(fig, 111)
fig.add_subplot(host)
# This is the heart of the example. We have to scale the axes correctly.
aux_trans = mtransforms.Affine2D().translate(0., 0.).scale(3600,
ydata1.max())
par = host.twin(aux_trans)
host.set_xlabel("Time [sfm]")
host.set_ylabel("Random Data 1")
par.set_ylabel("Random Data 2")
par.axis["right"].label.set_visible(True)
p1, = host.plot(time, ydata1)
p2, = par.plot(time, ydata2)
host.axis["left"].label.set_color(p1.get_color())
par.axis["right"].label.set_color(p2.get_color())
host.axis["bottom"].label.set_size(16)
host.axis["left"].label.set_size(16)
par.axis["right"].label.set_size(16)
# Move the title little upwards so it won't overlap with the ticklabels
title = plt.title("Double time: SFM and HH:MM:SS", fontsize=18)
title.set_position((0.5, 1.05))
plt.show()
### END CODE ###
-- 
Gökhan
From: per f. <per...@gm...> - 2009年09月27日 15:29:16
hi all,
i am trying to make a simple stacked bar graphs (just two layers) and
am getting some strange results. i have the following code:
import numpy as np
import matplotlib.pyplot as plt
ind = np.arange(3)
width = 0.35
plt.bar(ind, [5128307, 4305252, 4817425], width, align='center', color='r')
plt.bar(ind, [5969352, 5011032, 5590754], width, align='center',
bottom=[5128307, 4305252, 4817425], color='k')
i want it to be so that the bar graphs with values [5128307, 4305252,
4817425] appear in red "below" the taller bar graphs with values
[5969352, 5011032, 5590754]. when i try to plot this, i get a very
strange y-axis, formatted on a 1e7 scales, and the values appear
wrong.
if i modify my plot to simply be:
ind = np.arange(3)
width = 0.35
plt.bar(ind, [5969352, 5011032, 5590754], width, align='center', color='k')
then the y-axis appears correctly, with ylim set to 6 million. how can
i get the graph to look just like this, except have the stacked
smaller bar graphs appear in red?
any help on this would be greatly appreciated.
thanks.
From: butterw <bu...@gm...> - 2009年09月27日 14:13:05
Hi, 
thank you for clearing that up. 
Some feedback: If plotting a line2D as discrete points rather than a
continuous line, you must use numpoints=2 for the legend picking to actually
occur on the points. The alpha blending doesn't work on the legend symbols
however. 
Is there any other way, I can show in the legend whether the points of the
series are visible or not ? 
I thought of changing the labels, but failed to get them to redraw.
# plots:
ax.plot(t, y1, 'ro', picker=5, label='lab1')
ax.plot(t, y2, 'bo', picker=5, label='lab2')
# legend
leg = ax.legend(loc='upper left', numpoints=2, fancybox=True, shadow=True)
lines, labels = ax.get_legend_handles_labels()
# Enable picking on the legend lines
leglines=leg.get_lines()
for legline in leglines: legline.set_picker(5)
Jae-Joon Lee wrote:
> 
> On Wed, Sep 23, 2009 at 3:27 PM, butterw <bu...@gm...> wrote:
>>
>> Hi,
>>
>> pickers work great to make matplotlib plots more interactive/general user
>> friendly.
>>
>> On the subject of the legend_picker.py example, I was wondering if it was
>> possible to combine both a legend picker and a line picker in the same
>> plot.
>> From what I gather they will both use the same onpick event callback.
>>
>> So my question is : How do I discriminate between a pick on the legend
>> from
>> a pick on a line ? The event.artist is a line2D in both cases.
> 
> As demonstrated in the above example, leg.get_lines() gives you the
> list of lines inside the legend. The list of original lines is kept in
> ax.lines.
> So, you can check in which list the given artist is.
> 
> Regards,
> 
> -JJ
> 
>>
>>
>>
>>
>>
>>
>> John Hunter-4 wrote:
>>>
>>> On Mon, Aug 3, 2009 at 11:38 PM, Gökhan Sever<gok...@gm...>
>>> wrote:
>>>> Hello,
>>>>
>>>> I was wondering if it is possible to hide some data on figures using a
>>>> say
>>>> right click option to any of the legend entry and make it temporarily
>>>> hidden/visible to better analyse the rest of the data?
>>>>
>>>> Check this screenshot for example:
>>>>
>>>> http://img25.imageshack.us/img25/9427/datahiding.png
>>>>
>>>> The red data clutters the rest of the figure, and I would like to be
>>>> able
>>>> to
>>>> hide it temporarily so that I can investigate the other two relations
>>>> more
>>>> easily.
>>>>
>>>> Any ideas? or alternative solutions?
>>>
>>> It's a nice idea, and should be doable with the pick interface we have
>>> for all mpl artists. Unfortunately, there were a few problems in the
>>> legend implementation which blocked the pick events from hitting the
>>> proxy lines they contained. I just made a few changes to mpl svn HEAD
>>> to support this, and added a new example.
>>>
>>> examples/event_handling/legend_picking.py
>>>
>>> which I'll include below. JJ could you review the changes to
>>> legend.py?
>>>
>>> Instructions for checking out svn are at::
>>>
>>>
>>> http://matplotlib.sourceforge.net/faq/installing_faq.html#install-from-svn
>>>
>>> Here is the example:
>>>
>>> """
>>> Enable picking on the legend to toggle the legended line on and off
>>> """
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>>
>>> t = np.arange(0.0, 0.2, 0.1)
>>> y1 = 2*np.sin(2*np.pi*t)
>>> y2 = 4*np.sin(2*np.pi*2*t)
>>>
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>>
>>> line1, = ax.plot(t, y1, lw=2, color='red', label='1 hz')
>>> line2, = ax.plot(t, y2, lw=2, color='blue', label='2 hz')
>>>
>>> leg = ax.legend(loc='upper left', fancybox=True, shadow=True)
>>> leg.get_frame().set_alpha(0.4)
>>>
>>>
>>> lines = [line1, line2]
>>> lined = dict()
>>> for legline, realine in zip(leg.get_lines(), lines):
>>> legline.set_picker(5) # 5 pts tolerance
>>> lined[legline] = realine
>>>
>>> def onpick(event):
>>> legline = event.artist
>>> realline = lined[legline]
>>> vis = realline.get_visible()
>>> realline.set_visible(not vis)
>>> fig.canvas.draw()
>>>
>>> fig.canvas.mpl_connect('pick_event', onpick)
>>>
>>> plt.show()
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Hiding-data-via-legend-tp24802219p25531267.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register
>> now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register
> now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://www.nabble.com/Hiding-data-via-legend-tp24802219p25633860.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Eric F. <ef...@ha...> - 2009年09月27日 07:12:32
Dr. Phillip M. Feldman wrote:
> I'd like to be able to create and use a custom colormap. I'm creating the
> colormap via
> the following statement:
> 
> matplotlib.colors.ListedColormap([(0,0,0),(0.6,0,0),(0,0.6,0),(0.6,0.6,0)],
> name='Earth')
Assign it to a variable, like
earth_cmap = matplotlib.colors.ListedColormap(
 [(0,0,0),(0.6,0,0),(0,0.6,0),(0.6,0.6,0)],
 name='Earth')
and then use cmap=earth_cmap as your kwarg specification.
The ability to register user-generated cmaps so that they can be 
retrieved via get_cmap is very new, and not present in 0.98.5. It is in 
the latest release (0.99.1), though. You would need to use the 
register_cmap function.
Eric
> 
> The above statement appears to work, but when I attempt to use this
> colormap, I
> get the error shown below. Any suggestions will be appreciated.
> 
> AssertionError Traceback (most recent call last)
> 
> art.py in <module>()
> 253
> 254 # Plot z as image using specified color map:
> --> 255 pyplot.imshow(z, origin='lower', cmap=get_cmap(map_names[n_map-1]),
> 256 extent=[x.min(),x.max(),y.min(),y.max()])
> 257
> 
> C:\Program
> Files\Python25\lib\site-packages\matplotlib-0.98.5.2n2-py2.5-win32.egg\matplotlib\cm.pyc
> in get_cmap(name, lut)
> 19 if lut is None: lut = mpl.rcParams['image.lut']
> 20
> ---> 21 assert(name in datad.keys())
> 22 return colors.LinearSegmentedColormap(name, datad[name], lut)
> 23
> 
> AssertionError:
From: Gökhan S. <gok...@gm...> - 2009年09月27日 06:25:26
On Sat, Sep 26, 2009 at 10:16 PM, Jae-Joon Lee <lee...@gm...> wrote:
> The gradient, in general, is not supported by matplotlib yet.
> If you're only interested in raster format outputs (like png), I
> think you can use agg_filter functionality (but you need svn version
> of mpl).
>
Could you give me a pointer on this where to look for the agg_filter, since
the search option doesn't yield any helpful results.
I use the svn compiled matplotlib and docs.
Thanks.
> Other wise, I guess your best bet is to divide you line into many
> segments and color them differently.
>
> -JJ
>
>
> On Sat, Sep 26, 2009 at 10:27 PM, Gökhan Sever <gok...@gm...>
> wrote:
> > Hello,
> >
> > Is it possible use a gradient color say from blue to red and/or
> specifying
> > certain color threshold for a line plot (i.e I have air temperature
> plotted
> > and I want to segment the color of the plot for temp > 0C red, and below
> 0
> > make it blue.) Would be much nicer with gradient however I am content for
> > the second option as well :)
> >
> > Thanks.
> >
> > --
> > Gökhan
> >
> >
> ------------------------------------------------------------------------------
> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> > is the only developer event you need to attend this year. Jumpstart your
> > developing skills, take BlackBerry mobile applications to market and stay
> > ahead of the curve. Join us from November 9&#45;12, 2009. Register
> now&#33;
> > http://p.sf.net/sfu/devconf
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> >
>
-- 
Gökhan
From: Gökhan S. <gok...@gm...> - 2009年09月27日 06:22:44
On Sat, Sep 26, 2009 at 11:14 PM, Jae-Joon Lee <lee...@gm...> wrote:
> On Sat, Sep 26, 2009 at 11:10 PM, Gökhan Sever <gok...@gm...>
> wrote:
> > To run the code, you have to get nasafile.py and add this into your
> > PYTHONPATH, later get dccn_plot.py and
> > 09_03_26_11_36_15.dmtccnc.combined.raw file. nasafile.py has the NasaFile
> > class to read this ascii file.
> >
> > run as ./dccn_plot.py 09_03_26_11_36_15.dmtccnc.combined.raw
> >
>
> Please note that your entire application is hardly a "small, complete
> example".
> While I did download your code from the svn and ran it, but
> understand that it makes the job difficult and reduces your chance of
> getting help from the developers (or other users).
>
>
I know it is getting complex even for myself. Lots of data source and trying
to make a general reading routine is somewhat lowering the readability. You
should have seen this same code without classes in action. That NasaFile
class has helped me alot actually, but the extra functionality also adds
lots of lines of code there, too. Thinking of moving this to a GUI.
Nevertheless for the time being I am talking in a more speculative way.
>
> > I have changed the code as you suggested. Here is the result:
> > http://img44.imageshack.us/img44/1075/newsso.png
> >
> > Two things I notice, right y-axis label is gone, and latter the top
> x-axis
> > nicely added there but it a replicate of bottom x-axis. Doing this:
>
> For the diappearing label,
> unfortunately, the axes_grid toolkits has slightly different behavior
> from mainline mpl.
>
>
> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#id5
>
>
> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html
>
> Adding
>
> pary.axis["right"].label.set_visible(True)
>
> in your code will work.
>
Thanks, this worked.
>
> At second thought, this might be a bug in the axes_grid toolkit.
>
> For your second point.
> There is a reason that I used a factor 3600 in my first example.
>
> aux_trans = mtransforms.Affine2D().scale(3600., y_max) # transform
> from ax2 to ax1
>
Added this line to the code:
aux_trans = mtransforms.Affine2D().translate(0., 0.).\
 scale(3600, dccn.data['dccnConSTP'].max())
See how the output looks like :
http://img18.imageshack.us/img18/5056/newss2.png
As you might see, the pary plotting disappears, when I use this scaling
which seemingly correct scaling for my case. It remedies the top axis
properly. They are correct equivalences of second-from-midnight
representation of time, i.e 45000 --> 12:30:00 (12.5)
When I play a little bit more in IPython (Still experiment, not in a
production stage :)) when the figure is up:
pary.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
Then it turns wrong: http://img3.imageshack.us/img3/4707/newss3.png
Either my understanding, or somethings internally in formatting code.
So close, these things are not easy to figure out. And to me these are
beyond advanced matplotlib functionality. I will put a more simplified
sample code once I figure out this.
Thank you again.
> You need to try to understand the units for date-time display and then
> figure out the correct transform for your need.
> If you try 3600, the unit will show as hours. But you may need some
> more work to make it fit your need.
>
> -JJ
>
>
> >
> > from matplotlib.dates import DateFormatter, HourLocator
> > locator = HourLocator()
> > pary.xaxis.set_major_locator(locator)
> > formatter = DateFormatter(r'$%H^h
> > )
> > ax2.xaxis.set_major_formatter(formatter)
> >
> > results with my IPython session crashed:
> >
> > RuntimeError: Locator attempting to generate 216001 ticks from 41000.0 to
> > 50000.0: exceeds Locator.MAXTICKS
> >
> >
> > I want to be able see in this fashion:
> >
> > I[3]: current_axis = gca()
> > I[4]: current_axis.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
> >
> > but this returns the bottom x-axis and changes them to all 00:00:00.
>
-- 
Gökhan
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 04:49:15
On Mon, Sep 21, 2009 at 10:32 AM, Christian Meesters
<mee...@im...> wrote:
> Hi,
>
> I'm plotting 2D-ndarrays with pylab.pcolor(). The data contain masked
> values and it can happen that entire rows or columns hold only masked
> values. Is there a build-in way to omitted such rows/columns? Currently
> I'm removing the labels in x and y and the row/columns by hand.
It is not clear what you're trying to do here. Masked values are not
plotted by default. You want tick labels not shown for those
row/column? There is no such built-in functionality. But you can
easily check if the row/column is empty for the given tick location
and then make the associated ticklabel invisible.
-JJ
>
> TIA
> Christian
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 04:39:49
Try something like below (there may be better ways to iterate over
indices but the below is what I can think of now).
-JJ
idxy, idxx = np.indices(tmat.shape)
for ix, iy in zip(idxx.flat, idxy.flat):
 text(ix-0.5, iy+0.5, "%4.1f"%tmat[iy, ix],
 fontsize=12,color='b',name='serif')
On Thu, Sep 24, 2009 at 3:34 AM, Bala subramanian
<bal...@gm...> wrote:
> Friends,
>
> I have a matrix which i plotted with matshow as follows and then used text
> function to write the each value inside the figure by choosing x and y
> coordinate. I wish to know if there is any easy or more fancy way to do the
> same.
>
> mat=load('tnz.txt')
> In [3]: tmat=transpose(mat)
> In [4]: tmat
> Out[4]:
> array([[ 10.2 , 26.4 , 12.2 , 13.6 , 24.6 , 13.9 , 10.2 , 20.6 ,
>     17. , 14.9 , 24.2 , 13. ],
>    [ 13.6 , 26.2 , 10.5 , 13.6 , 26.8 ,  9.87, 11. , 23.1 ,
>     14.7 , 16.7 , 25.3 , 15.6 ],
>    [ 10.7 , 22.4 ,  6. , 11.8 , 23.8 ,  7.4 ,  6.7 , 20.9 ,
>     10.3 , 12.5 , 20.9 ,  7.9 ]])
> In [5]: matshow(tmat,cmap=cm.autumn)
> Out[5]: <matplotlib.image.AxesImage object at 0x9a2c7cc>
>
> Now i wanted to give the show the values in the matrix using the text
> function as follows
>
>
> In [8]: text(-.489,.511,'10.2',fontsize=12,color='b',name='serif')
> Out[8]: <matplotlib.text.Text object at 0x9a41e2c>
>
> In [9]: text(.495,.511,'26.4',fontsize=12,color='b',name='serif')
> Out[9]: <matplotlib.text.Text object at 0x9a489ac>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 04:27:19
On Sat, Sep 26, 2009 at 11:41 PM, Phillip M. Feldman
<pfe...@ve...> wrote:
> Re. working on the documentation: I'd be happy to contribute. How do I edit
> the docs?
While it is best to submit a patch against svn,
http://matplotlib.sourceforge.net/faq/howto_faq.html?highlight=contribute#contribute-to-matplotlib-documentation
For simple changes, you may just post those changes in this mailing list.
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 04:15:03
On Sat, Sep 26, 2009 at 11:10 PM, Gökhan Sever <gok...@gm...> wrote:
> To run the code, you have to get nasafile.py and add this into your
> PYTHONPATH, later get dccn_plot.py and
> 09_03_26_11_36_15.dmtccnc.combined.raw file. nasafile.py has the NasaFile
> class to read this ascii file.
>
> run as ./dccn_plot.py 09_03_26_11_36_15.dmtccnc.combined.raw
>
Please note that your entire application is hardly a "small, complete example".
While I did download your code from the svn and ran it, but
understand that it makes the job difficult and reduces your chance of
getting help from the developers (or other users).
> I have changed the code as you suggested. Here is the result:
> http://img44.imageshack.us/img44/1075/newsso.png
>
> Two things I notice, right y-axis label is gone, and latter the top x-axis
> nicely added there but it a replicate of bottom x-axis. Doing this:
For the diappearing label,
unfortunately, the axes_grid toolkits has slightly different behavior
from mainline mpl.
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#id5
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/axislines.html
Adding
pary.axis["right"].label.set_visible(True)
in your code will work.
At second thought, this might be a bug in the axes_grid toolkit.
For your second point.
There is a reason that I used a factor 3600 in my first example.
aux_trans = mtransforms.Affine2D().scale(3600., y_max) # transform
from ax2 to ax1
You need to try to understand the units for date-time display and then
figure out the correct transform for your need.
If you try 3600, the unit will show as hours. But you may need some
more work to make it fit your need.
-JJ
>
> from matplotlib.dates import DateFormatter, HourLocator
> locator  = HourLocator()
> pary.xaxis.set_major_locator(locator)
> formatter = DateFormatter(r'$%H^h
> )
> ax2.xaxis.set_major_formatter(formatter)
>
> results with my IPython session crashed:
>
> RuntimeError: Locator attempting to generate 216001 ticks from 41000.0 to
> 50000.0: exceeds Locator.MAXTICKS
>
>
> I want to be able see in this fashion:
>
> I[3]: current_axis = gca()
> I[4]: current_axis.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
>
> but this returns the bottom x-axis and changes them to all 00:00:00.
From: Phillip M. F. <pfe...@ve...> - 2009年09月27日 03:41:20
I downloaded the latest version of EPD and installed, and register_cmap 
now works.
Thanks!
Re. working on the documentation: I'd be happy to contribute. How do I 
edit the docs?
Phillip
Jae-Joon Lee wrote:
> It seems that you're using an older version of matplotlib.
> register_cmap is available in the current version of mpl, which is
> 0.99.1. And the example works fine.
>
> While it is best if the documentation states which functionality
> became available at which version, unfortunately it is not. If you
> want to contribute, it is always welcomed.
>
> -JJ
>
>
> On Sat, Sep 26, 2009 at 9:27 PM, Dr. Phillip M. Feldman
> <pfe...@ve...> wrote:
> 
>> When I try to import register_cmap from matplotlib, matplotlib.colors, or any
>> of the other likely candidate modules in which it might be contained, I get
>> a "cannot import" error. It would be great if the documentation indicated
>> how to import this and provided at least one working example.
>> --
>> View this message in context: http://www.nabble.com/where-does-register_cmap-come-from--tp25630125p25630125.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> 
>
> 
From: Jae-Joon L. <lee...@gm...> - 2009年09月27日 03:16:33
The gradient, in general, is not supported by matplotlib yet.
If you're only interested in raster format outputs (like png), I
think you can use agg_filter functionality (but you need svn version
of mpl).
Other wise, I guess your best bet is to divide you line into many
segments and color them differently.
-JJ
On Sat, Sep 26, 2009 at 10:27 PM, Gökhan Sever <gok...@gm...> wrote:
> Hello,
>
> Is it possible use a gradient color say from blue to red and/or specifying
> certain color threshold for a line plot (i.e I have air temperature plotted
> and I want to segment the color of the plot for temp > 0C red, and below 0
> make it blue.) Would be much nicer with gradient however I am content for
> the second option as well :)
>
> Thanks.
>
> --
> Gökhan
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Gökhan S. <gok...@gm...> - 2009年09月27日 03:15:02
On Sat, Sep 26, 2009 at 9:58 PM, Jae-Joon Lee <lee...@gm...> wrote:
> As specified in the doc
>
>
> http://matplotlib.sourceforge.net/api/axis_api.html?highlight=get_majorticklabels#matplotlib.axis.Axis.get_majorticklabels
>
> it returns a list of Text instances. You may use
>
>
> http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.text.Text.get_text
>
> to retrieve the strings associated.
> For example,
>
> [t.get_text() for t in ax.xaxis.get_majorticklabels()]
>
> -JJ
>
Yes, got it. Thanks.
From: Gökhan S. <gok...@gm...> - 2009年09月27日 03:10:17
On Sat, Sep 26, 2009 at 9:50 PM, Jae-Joon Lee <lee...@gm...> wrote:
> On Fri, Sep 25, 2009 at 1:14 AM, Gökhan Sever <gok...@gm...>
> wrote:
> > With twin and proper Affine2D transformation I could not make the
> secondary
> > y-axis data being shown on the figure.
>
> Please post a simple, complete code that does not work.
> Just saying "it didn't work" does not help.
>
> I think the following change (or something like this) in you code
> (dccn_plot.py) seems to work to my eyes. If this is not what you want,
> you have to describe why it is not.
>
> import matplotlib.transforms as mtransforms
> aux_trans = mtransforms.Affine2D().translate(0., -0.5).scale(1., 3500/0.45)
> #pary = host.twinx()
> pary = host.twin(aux_trans)
>
> Regards,
>
> -JJ
>
OK JJ, trying to be more descriptive.
To run the code, you have to get nasafile.py and add this into your
PYTHONPATH, later get dccn_plot.py and 09_03_26_11_36_15.dmtccnc.combined.raw
file. nasafile.py has the NasaFile class to read this ascii file.
run as ./dccn_plot.py 09_03_26_11_36_15.dmtccnc.combined.raw
I have changed the code as you suggested. Here is the result:
http://img44.imageshack.us/img44/1075/newsso.png
Two things I notice, right y-axis label is gone, and latter the top x-axis
nicely added there but it a replicate of bottom x-axis. Doing this:
from matplotlib.dates import DateFormatter, HourLocator
locator = HourLocator()
pary.xaxis.set_major_locator(locator)
formatter = DateFormatter(r'$%H^h$')
ax2.xaxis.set_major_formatter(formatter)
results with my IPython session crashed:
RuntimeError: Locator attempting to generate 216001 ticks from 41000.0 to
50000.0: exceeds Locator.MAXTICKS
I want to be able see in this fashion:
I[3]: current_axis = gca()
I[4]: current_axis.xaxis.set_major_formatter(DateFormatter('%H:%M:%S'))
but this returns the bottom x-axis and changes them to all 00:00:00.
-- 
Gökhan

Showing results of 36

1 2 > >> (Page 1 of 2)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /