clabel and bbox

Hello!
Is it possible to add a bbox behind a clabel, like one can do with a plt.text or something that would look similar?

Best regards,
Andres

The clable command returns a list of Text instances.
You need call set_bbox method for each of them.

tl = clabel(...)
for t in tl:
    t.set_bbox(dict(fc="y"))

For clabels, which are often rotated, it may better to use fancy box
style (the default bbox is not rotated even though the text is).

  t.set_bbox(dict(boxstyle="round",fc="y"))

Regards,

-JJ

···

On Sat, Aug 1, 2009 at 5:32 AM, Andres Luhamaa<andres.luhamaa@...1716...> wrote:

Hello!
Is it possible to add a bbox behind a clabel, like one can do with a
plt.text or something that would look similar?

Best regards,
Andres

------------------------------------------------------------------------------
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

Thank You,

but now I have another little annoying issue. Besides clabel I add some text manually to my plot with plt.text and sometimes the clabel and plt.text overlap, and no matter in which order I plot them, the string from clabel is always above the one from plt.text, but I would like, if the manually added text would be more visible.

So, is there a way to prevent the clabel text from appearing above other text in my plot? I can make a little workaround by getting clabel coordinates and then trying to guess if they overlap with my text and then set the particular clabel invisible. But at the moment it seems I need to do additional calculations to get the actual size of text boxes and maybe there is a more elegant solution, still?

Best regards,
Andres

Jae-Joon Lee wrote:

···

The clable command returns a list of Text instances.
You need call set_bbox method for each of them.

tl = clabel(...)
for t in tl:
    t.set_bbox(dict(fc="y"))

For clabels, which are often rotated, it may better to use fancy box
style (the default bbox is not rotated even though the text is).

  t.set_bbox(dict(boxstyle="round",fc="y"))

Regards,

-JJ

On Sat, Aug 1, 2009 at 5:32 AM, Andres Luhamaa<andres.luhamaa@...1716...> wrote:
  

Hello!
Is it possible to add a bbox behind a clabel, like one can do with a
plt.text or something that would look similar?

Best regards,
Andres

------------------------------------------------------------------------------
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

please define "more visible".
Maybe adjusting the zorder is sufficient?

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=zorder#matplotlib.artist.Artist.set_zorder

If not, I would adjust the clable position manually (of course, this
is not a good choice if you need to do this for a lot of plots).
I'm not sure if there are more elegant solutions.

-JJ

···

On Sat, Aug 1, 2009 at 5:04 PM, Andres Luhamaa<andres.luhamaa@...1716...> wrote:

Thank You,

but now I have another little annoying issue. Besides clabel I add some
text manually to my plot with plt.text and sometimes the clabel and
plt.text overlap, and no matter in which order I plot them, the string
from clabel is always above the one from plt.text, but I would like, if
the manually added text would be more visible.

Jae-Joon Lee wrote:

  

Thank You,

but now I have another little annoying issue. Besides clabel I add some
text manually to my plot with plt.text and sometimes the clabel and
plt.text overlap, and no matter in which order I plot them, the string
from clabel is always above the one from plt.text, but I would like, if
the manually added text would be more visible.

please define "more visible".
Maybe adjusting the zorder is sufficient?

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=zorder#matplotlib.artist.Artist.set_zorder

If not, I would adjust the clable position manually (of course, this
is not a good choice if you need to do this for a lot of plots).
I'm not sure if there are more elegant solutions.

-JJ
  

Thank You once more, zorder is good but I also found the solution I was really looking for.
Combination of get_window_extent and count_overlaps lets easily find overlapping text and just set clabels invisible. I add an example (modified from contour_demo.py) for future reference, if anyone is interested.

Best regards,
Andres

contourtest.py (1.49 KB)

···

On Sat, Aug 1, 2009 at 5:04 PM, Andres Luhamaa<andres.luhamaa@...1716...> wrote: