Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 07 20:21
    Phlya commented #85
  • Aug 07 20:01
    RolandBacon commented #85
  • Aug 06 17:39
    Phlya commented #85
  • Aug 06 16:52
    RolandBacon opened #85
  • Jun 23 14:40
    jolespin commented #84
  • Jun 23 12:53
    Phlya commented #84
  • Jun 22 23:38
    jolespin commented #84
  • Jun 22 10:29
    Phlya commented #84
  • Jun 21 19:20
    jolespin opened #84
  • Jun 17 20:57
    Phlya commented #83
  • Jun 17 18:58
    scherman edited #83
  • Jun 17 18:56
    scherman edited #83
  • Jun 17 18:47
    scherman opened #83
  • Jun 16 13:33
    Phlya closed #81
  • Jun 16 13:33
    Phlya commented #81
  • Jun 13 10:10
    Alalalalaki closed #82
  • Jun 13 10:10
    Alalalalaki commented #82
  • Jun 12 22:32
    Phlya commented #82
  • Jun 12 19:54
    Alalalalaki opened #82
  • Jun 12 11:27
    Phlya commented #81
David Slochower
@slochower
If I add a bbox to my labels (like a white background), is there a way for adjust_text to take this into account? I think this might be related to add_objects (issue #76) but I can't figure it out.
David Slochower
@slochower

~The situation I've run into is that texts created outside of a loop will be managed by adjust_text, but texts created inside of a particular loop will not. I can show a code snippet on the Issue tracker, if interested.~

Whoops, user error. Inside of a loop I was reinitializing the texts list, so adjust_text only knew about the final one, yet the plot was annotated correctly so it looked like an adjust_text problem, but it was really just my problem. Sorry for the noise.

Ilya Flyamer
@Phlya
Hi, so it works for you in the end, as far as I understand?
David Slochower
@slochower
Yep. Sometimes things look a little nonoptimized when I draw a white box behind the labels, because I'm not sure those objects are taken into account, but otherwise things are working :)

For example, background and labeled points overlap: https://pasteboard.co/I8COIOT.png (look at the light green text and white box, which is covering the light green point near the bottom of the "p" in "a-hpa-p").

In this case, I'm using

    texts.append(plt.text(i + 0.3, j, k, size=28, color = colors[index], bbox=dict(facecolor="w", alpha=0.8)))

with the default adjust_text(texts).

Ilya Flyamer
@Phlya
why are you doing i+0.3?
David Slochower
@slochower
That was an attempt to help move the boxes so they didn't overlap the points. I actually get the same identical result with and without that + 0.3
Ilya Flyamer
@Phlya
I expected this would work fine, since the algorithm actually uses bbox coordinates to calculate overlaps... But for you increasing expand_points should help, probably.
David Slochower
@slochower
Right. It does :)
expand_points=(1.2, 1.2) helps a lot.
Ilya Flyamer
@Phlya
Cool
Not sure why it doesn't work by default, but hopefully this is an acceptable solution
David Slochower
@slochower
To be clear, expand_points makes the points look bigger, and expand_objects makes the objects, like bboxs behave as though they are bigger?
Ilya Flyamer
@Phlya
No, all expand arguments actually expand text bboxes, but for comparisons with different kinds of objects - so expand_points expands text bboxes when overlapping them with points, and so on
David Slochower
@slochower
Ah okay, thanks. I didn't get that distinction before.
Ilya Flyamer
@Phlya
Yeah, sorry, it's quite subtle
David Slochower
@slochower
Occasionally, I still get clashes -- slighlty different graph, this time running with expand_points=(2,2) and expand_text=(1.2, 1.4), parameters that I found empirically to work well. See the label for b-hex is overlapping two points. Is there a quick and dirty way to just increase the force parameters to push this away from the points? (It may not be worth really troubleshooting, because these parameters work pretty well for a number of similar graphs...) https://pasteboard.co/I8DjGMS.png
Ilya Flyamer
@Phlya
Yeah, just increase the force...
Also, it won't repel from other points if you don't specify their coordinates (or provide the output of scatter in the add_objects)
David Slochower
@slochower
Aha
Yeah, I see.
In this case, I was trying to be fancy by increasing the radius of the highlighted points, then drawing patch Circles and passing the patches to adjust_text
But I should also pass the underlying data points, and then I get the expected behavior.
Ilya Flyamer
@Phlya
wow I see
David Slochower
@slochower
Thanks for your help!
Ilya Flyamer
@Phlya
yep
David Slochower
@slochower
This was very useful.
Ilya Flyamer
@Phlya
you are welcome!