Coder Social home page Coder Social logo

A challenging scenario about adjusttext HOT 5 CLOSED

alphapapa avatar alphapapa commented on August 19, 2024
A challenging scenario

from adjusttext.

Comments (5)

Phlya avatar Phlya commented on August 19, 2024
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-db2cb0873245> in <module>()
    481 # Convert date fields to datetime objects
    482 for frame in ['workouts']:
--> 483     frames[frame]['Date'] = frames[frame]['Date'].apply(pandas.to_datetime, format=FOOD_DATE_FORMAT)
    484 
    485 # Drop old data

NameError: name 'FOOD_DATE_FORMAT' is not defined

This is what I get when I try to run it...

But what's obvious is you shouldn't increase force and expand_points in such complicated scenarios, rather maybe decrease it from default (at least force). You may increase expand in y, but probably not in x, since it is proportional to the length of text and texts are already very long in your case. If you provide an example which can be easily run, I can try to help you with it better.

from adjusttext.

alphapapa avatar alphapapa commented on August 19, 2024

Oops, sorry about that, I was trying to whittle it down some more, and I accidentally cut out the wrong thing. I fixed it and updated the code.

I'll try what you suggested about force and expand_points, but IIRC it was only by changing them to what they are now that I was able to get it this readable. :) Thanks for your help.

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

This is what I got now... Were you maybe running it in Python 3? I only have Python 2 installed and set up on my laptop now.

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-1-39eade804e60> in <module>()
    654         labels[num].set_fontproperties(FontProperties(weight=1000))
    655     else:
--> 656         labels[num].set_text(date.strftime('%b'))
    657         labels[num].set_fontproperties(FontProperties(weight=1000))
    658 calories_plot.xaxis.set_ticklabels(labels, rotation=0, color=c.base01)

/usr/local/lib/python2.7/dist-packages/matplotlib/text.pyc in set_text(self, s)
   1204         ACCEPTS: string or anything printable with '%s' conversion.
   1205         """
-> 1206         self._text = '%s' % (s,)
   1207         self.stale = True
   1208 

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

Also, adjust_text never puts text outside axes boundaries, it even forces all provided text objects to be fully inside - I suppose what you see about that is because you actually change the boundaries after adjusting text...

from adjusttext.

alphapapa avatar alphapapa commented on August 19, 2024

No, I'm only using Python 2. I'm quite mystified, because it works fine for me, both when running it from within Emacs (C-c C-c) and when running it from a shell (python script.py). I see ipython in that traceback--maybe it has something to do with that? I've never used ipython.

In any case, that code isn't relevant to this problem, so it can simply be removed. I cut it out and updated the code block again.

Also, adjust_text never puts text outside axes boundaries, it even forces all provided text objects to be fully inside - I suppose what you see about that is because you actually change the boundaries after adjusting text...

Ah, I see. Well, I tried calling adjust_text as the very last thing before the plot is shown, and it did stop the figure from increasing in size to show the off-subplot annotation, but now the annotation itself is off the figure completely:

figure_1-1

Thanks for your help, and sorry for the trouble in running that script.

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

Closing, unless this is still an issue?

from adjusttext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.