Re: [Matplotlib-users] Partial coloring of text in matplotlib

2012-02-07 Thread Yann Tambouret
Along the lines of Mike's suggestion, I thought this could be done using
Latex.


I posted an answer on SO with an example of doing this, but it seems only
to work with postscript backend. Other backends override the color with the
mpl text color setting.

Is there a way to prevent this override? For example don't try to use 'PS'
backend, and look at hte figure interactively. It defaults to black.

http://stackoverflow.com/a/9185143/717357

-Yann



On Tue, Feb 7, 2012 at 4:46 PM, Paul Ivanov pivanov...@gmail.com wrote:

 Benjamin Root, on 2012-02-07 13:46,  wrote:
  Also, how deep should this rabbit hole go?  I could imagine one could
 want
  this for title() and figtitle().  Maybe it would be best to implement
 this
  at the Text() constructor level?

 For this reason, I would discourage even implementing such
 functionality in the core of matplotlib. This functionality doesn't strike
 me
 as something that ought to be available everywhere by default - if someone
 needs it, they can implement it as follows:

 -
 import matplotlib.pyplot as plt
 from matplotlib import transforms

 def rainbow_text(x,y,ls,lc,**kw):

Take a list of strings ``ls`` and colors ``lc`` and place them next to
 each
other, with text ls[i] being shown in color lc[i].

This example shows how to do both vertical and horizontal text, and will
pass all keyword arguments to plt.text, so you can set the font size,
family, etc.

t = plt.gca().transData
fig = plt.gcf()
plt.show()

#horizontal version
for s,c in zip(ls,lc):
text = plt.text(x,y, +s+ ,color=c, transform=t, **kw)
text.draw(fig.canvas.get_renderer())
ex = text.get_window_extent()
t = transforms.offset_copy(text._transform, x=ex.width,
 units='dots')

#vertical version
for s,c in zip(ls,lc):
text = plt.text(x,y, +s+ ,color=c, transform=t,
rotation=90,va='bottom',ha='center',**kw)
text.draw(fig.canvas.get_renderer())
ex = text.get_window_extent()
t = transforms.offset_copy(text._transform, y=ex.height,
 units='dots')


 plt.figure()
 rainbow_text(0.5,0.5,all unicorns poop rainbows ! ! !.split(),
['red', 'orange', 'brown', 'green', 'blue', 'purple', 'black'],
size=40)

 best,
 --
 Paul Ivanov
 314 address only used for lists,  off-list direct email at:
 http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7


 --
 Keep Your Developer Skills Current with LearnDevNow!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-d2d
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Strange default choice of ylabel ticks

2012-01-18 Thread Yann Tambouret
Hi Per,

I think you want to use the 'ticklabel_format' method:

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.ticklabel_format

Here's your example modified some. 'some_point2A.pdf' produces exactly the
same as the default. 'some_point2B.pdf' does not use an offset, and maybe
produces more of what you were looking for.

import pylab as pl

some_points = [0.94589396231920286, 0.94593953605915637,
0.94601787712257401, 0.94597530431819743, 0.9459922123931529,
0.94622433138703055]
pl.plot(some_points, '.-')

pl.ticklabel_format(style='plain',useOffset=0.9458,axis='y')
pl.savefig('some_point2A.pdf')
pl.ticklabel_format(style='plain',useOffset=False,axis='y')
pl.savefig('some_point2B.pdf')

-Yann



On Wed, Jan 18, 2012 at 4:15 AM, Per Nielsen evil...@gmail.com wrote:

 Hi all

 I get a rather strange scaling / choice of y-axis ticks for the following
 script:

 import pylab as pl

 some_points = [0.94589396231920286, 0.94593953605915637,
 0.94601787712257401, 0.94597530431819743, 0.9459922123931529,
 0.94622433138703055]
 pl.plot(some_points, '.-')
 pl.savefig('some_point2.pdf')

 output here:

 http://dl.dropbox.com/u/2244215/some_point2.pdf

 This is a rather simple plot, but matplotlib choses a strange scaling of
 the y-axis by default. How do I get a more standard scaling without
 specifying the yticks manually?

 Best

 Per


 --
 Keep Your Developer Skills Current with LearnDevNow!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-d2d
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How do you change the position of an annotation?

2012-01-13 Thread Yann Tambouret
I'm trying to update the position of an annotation. If I add an annotation,
change it's position using set_position, I find the value of the position
(found using get_position) is updated, but the actual position on the
figure does not change. How can I actually change the position of the text
and starting point of the corresponding arrow?

Here's an example:

import matplotlib.pyplot as plt

data = [10, 8, 8, 5]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.bar(range(len(data)),data)
ax.set_ylim(0,max(data)+2)
annotationPos1 = ax.annotate(Really long and large label,fontsize=12,
 xy=(1.4,8),
 xytext=(1.4,8.5),
 arrowprops=dict(arrowstyle=-)
 )

annotationPos2 = ax.annotate(Really long and large label,fontsize=12,
 xy=(1.4,8),
 xytext=(1.4,10.5),
 arrowprops=dict(arrowstyle=-)
 )

apos1before = annotationPos1.get_position()
annotationPos1.set_position((apos1before[0],apos1before[1]+2))
apos1after = annotationPos1.get_position()
apos2 = annotationPos2.get_position()
print apos1before,apos1after,apos2
plt.show()


Thanks, Yann
--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] small bug in Axes.add_artist method

2009-10-19 Thread Yann Goudard
Hi,

I found a small bug in matplotlib.axes.Axes.add_artist method. 
matplotlib.artist.Artist.set_axes method is called twice.

def add_artist(self, a):
 '''
 Add any :class:`~matplotlib.artist.Artist` to the axes.

 Returns the artist.
 '''
 * a.set_axes(self) *
 self.artists.append(a)
 self._set_artist_props(a)
 a.set_clip_path(self.patch)
 a._remove_method = lambda h: self.artists.remove(h)
 return a

def _set_artist_props(self, a):
 'set the boilerplate props for artists added to axes'
 a.set_figure(self.figure)
 if not a.is_transform_set():
 a.set_transform(self.transData)

 * a.set_axes(self) *

matplotlib version: 0.99.1.1

Regards,

Yann



--
Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Text backgroundcolor and edgecolor

2009-10-09 Thread Yann Goudard
Hi,

I found strange behavior in matplotlib.text.Text. 
set_backgroundcolor(self, color) allows to init text background and edge 
colors but we can only alter backgroundcolor.

# line 728
def set_backgroundcolor(self, color):
 
 Set the background color of the text by updating the bbox.

 .. seealso::

 :meth:`set_bbox`
To change the position of the bounding box.

 ACCEPTS: any matplotlib color
 
 if self._bbox is None:
 self._bbox = dict(facecolor=color, edgecolor=color)
 else:
 self._bbox.update(dict(facecolor=color))

I think the last line might be like :
self._bbox.update(dict(facecolor=color, edgecolor=color))

I notice it because I use a dark background for axis and texts but I 
replace it by a white one when I print figure. With current code, it 
remains a dark border arround my texts.

Regards,

Yann




--
Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] hatch does not work with zoom

2009-10-09 Thread Yann Goudard
Hi,

I notice hatch is not drawn correctly when I zoom in axes.

#!/usr/bin/env python
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

axes = plt.subplot(111)
axes.add_patch(Rectangle((0, 0), 1, 1, fill=False, hatch=/))
plt.show()

Is there a way to fix it ?

Regards,

Yann



--
Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] hatch does not work with zoom

2009-10-09 Thread Yann Goudard
I applied the patch to the tarball and built. It works perfectly.
Your responsiveness is very impressive.
Thanks,

Yann

On 10/09/2009 05:27 PM, Michael Droettboom wrote:
 Thanks.  This is definitely a bug.  I just fixed it in SVN r7858.

 http://matplotlib.svn.sourceforge.net/viewvc/matplotlib?view=revrevision=7858
  


 Unfortunately, this requires a recompile.  You can build from SVN, or 
 download the 0.99.1 tarball and manually apply the above patch.

 Mike

 Yann Goudard wrote:
 Hi,

 I notice hatch is not drawn correctly when I zoom in axes.

 #!/usr/bin/env python
 import matplotlib.pyplot as plt
 from matplotlib.patches import Rectangle

 axes = plt.subplot(111)
 axes.add_patch(Rectangle((0, 0), 1, 1, fill=False, hatch=/))
 plt.show()

 Is there a way to fix it ?

 Regards,

 Yann



 --
  

 Come build with us! The BlackBerry(R) 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 - 12, 2009. Register 
 now!
 http://p.sf.net/sfu/devconference
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users





--
Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] grid on log-plots

2009-09-09 Thread Yann
I can not try your revision but I will do it as soon as it is released.
Nervertheless I try your snippet with an AxesZero. I get the gridlines 
and the axis but the first was over the second. It is not what I expected.
As far as I am concerned, I can wait until matplotlib next release.

Thanks,

Yann

On 09/08/2009 08:13 PM, Jae-Joon Lee wrote:
 On Tue, Sep 8, 2009 at 11:51 AM, Yann
 Goudardmatplotlib-us...@alleeduweb.eu  wrote:

 Hi,

 I have the same behaviour with LocatableAxes. HostAxes, ParasiteAxes and
 LocatableAxes depend on 'mpl_toolkits.axes_grid.axislines.Axes'. It must
 be the matter origin.
  
 Yes, and this was because I forgot to implement some necessary methods.
 This is now fixed in the svn trunk. So if you can,please give it a try.


 This another example should draw a grid but does not:

 import wx
 from wx import Frame
 from matplotlib.backends.backend_wxagg import FigureFrameWxAgg,
 FigureCanvasWxAgg
 from matplotlib.figure import Figure
 from mpl_toolkits.axes_grid.axes_divider import LocatableAxes

 fig = Figure((1, 1), 50)
 axes = LocatableAxes(fig, [0, 0, 1, 1])
 # axes.toggle_axisline(False)
 axes.grid(True)
 fig.add_axes(axes)

 app = wx.PySimpleApp()
 my_viewer = FigureFrameWxAgg(-1, fig)
 my_viewer.Show()
 app.MainLoop()

 If you uncomment axes.toggle_axisline(False), it works cause it uses
 normal 'matplolib.axes.Axes' behaviour. It is not a matter for common
 use but if you need 'AxesZero', this trick does not work.
  
 What the toggle_axisline does is simply to make the xaxis and yaxis
 (which are responsible for drawing ticks, ticklabels, etc  in the
 mainline mpl) visible again, and make axis[bottom] and etc
 invisible.
 One workaround is to make xaxis and yaxis visible but pnly to draw the
 gridlines. Something like below.

 ax.toggle_axisline(True)
 ax.grid(True)
 ax.gridlines.set_visible(False) # this is just to make the code not to
 draw gridlines twice in future release of mpl.
 ax.xaxis.set_visible(True)
 ax.yaxis.set_visible(True)
 for t in ax.xaxis.majorTicks + ax.yaxis.majorTicks:
  t.gridOn = True
  t.tick1On = False
  t.tick2On = False
  t.label1On = False
  t.label2On = False

 Let me know if this does not work, or there is a case that this cannot be 
 used.
 Regards,

 -JJ



 Yann


 On 09/07/2009 10:37 PM, Andreas Fromm wrote:
  
 thanks Sebastian,

 you are right, your code works here too. But i don't get it work in my
 multi y-axes plot from the matplotlib examples
 (http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes.html).
 Even with linear plots, i get no gridlines.

 Any idea, whats wrong here?

 minimal code example:
 ###
 import matplotlib.pyplot as plt
 from mpl_toolkits.axes_grid.parasite_axes import HostAxes, ParasiteAxes

 fig = plt.figure(1)
 fig.clf()
 #plt.grid(True)
 host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8])
 fig.add_axes(host)

 host.plot([0, 10, 100], [0, 10, 100], label='host')

 host.grid(True)  #?
 host.yaxis.grid(True) #?

 host.yaxis.set_scale('log') #?

 plt.draw()
 plt.show()
 ###

 Greets,
 Andreas


 Sebastian Busch schrieb:


 from matplotlib.pyplot import *

 plot([1,10,100],[1,10,100])
 grid()

 yscale('log')
 xscale('log')

 works here.

 best,
 sebastian.


  
 --
 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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users





 --
 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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

  


--
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users