Comments (11)
BTW I am using Python 3.5.
from adjusttext.
Looks like the code that you used for changing locale is for linux. These are the codes for windows .
Using these codes I was able to change the locale settings but I am still getting the same error as above when using adjustText. I tried both 'english-uk' and 'english-us'.
from adjusttext.
Can you provide the code to reproduce this error?
I never use anything with time series myself, so don't know much about this...
And about the locale, I had the problem because mine was set to Russian, if your system in in English it should be fine I think.
from adjusttext.
Here is some sample code. I am using Windows and python 3.5.
import matplotlib.pyplot as plt
from adjustText import adjust_text
import datetime
import random
x = [datetime.datetime.now() + datetime.timedelta(days=i) for i in range(30)]
y = [i+random.gauss(0,1) for i,_ in enumerate(x)]
plt.plot_date(x,y)
plt.gcf().autofmt_xdate()
texts = []
for i,_ in enumerate(x):
texts.append(plt.text(x[i],y[i],round(y[i],3),fontsize=8))
adjust_text(texts, arrowprops=dict(arrowstyle="-", color='r', lw=0.5))
plt.show()
from adjusttext.
Can you try running the code from the examples? As I said, I have exactly zero experience with date/time plotting, so I don't know - could there be a difference between dates with mpl.mdates
and datetime
?
from adjusttext.
You are right. The error was because I need to convert the dates to number using
mdates.date2num() before passing it to adjust_text(). After doing this I am not getting any error.
from adjusttext.
Glad to hear, thanks! Can you show the final code that works here for future reference?
from adjusttext.
Sure. Here is a working example with plot_date:
import matplotlib.pyplot as plt
from adjustText import adjust_text
import datetime
import random
import matplotlib.dates as mdates
# make up some data
x = [datetime.datetime.now() + datetime.timedelta(days=i) for i in range(30)]
y = [i+random.gauss(0,1) for i,_ in enumerate(x)]
# plot
plt.plot_date(x,y)
# beautify the x-labels
plt.gcf().autofmt_xdate()
texts = []
for i,_ in enumerate(x):
texts.append(plt.text(mdates.date2num(x[i]),y[i],round(y[i],3),fontsize=8))
adjust_text(texts, arrowprops=dict(arrowstyle="-", color='r', lw=0.5))
plt.show()
from adjusttext.
Thank you!
This is better then, I guess? Seems like it works the same.
import matplotlib.pyplot as plt
from adjustText import adjust_text
import datetime
import random
import matplotlib.dates as mdates
# make up some data
x = [datetime.datetime.now() + datetime.timedelta(days=i) for i in range(30)]
y = [i+random.gauss(0,1) for i,_ in enumerate(x)]
x = mdates.date2num(x)
# plot
plt.plot_date(x,y)
# beautify the x-labels
plt.gcf().autofmt_xdate()
texts = []
for i,_ in enumerate(x):
texts.append(plt.text(x[i], y[i], round(y[i],3), fontsize=8))
adjust_text(texts, arrowprops=dict(arrowstyle="-", color='r', lw=0.5))
plt.show()
from adjusttext.
mdates.date2num(x)
is not needed, that was a typo. Infact x = mdates.date2num(x)
will give an error. I will edit my comment.
from adjusttext.
For me it works and doesn't require converting each x
value separately when adding texts.
from adjusttext.
Related Issues (20)
- Time Limit HOT 2
- Altering Data HOT 3
- Please be mindful of the versions HOT 10
- Example of integrating seaborn.object()
- Plotly support? HOT 1
- Feature request: Fix output (specify iteration limit instead of time) HOT 2
- Is the `bioframe` dependency necessary? HOT 3
- Just started not working one day with this error HOT 2
- Version 1.0.3 has a non declared dependency on pandas HOT 1
- force_points key word removed? HOT 2
- Labels misplaced in subplots HOT 1
- Issue with "matplotlib.axes.Axes.annotate" using the arguments "xytext" and "textcoords" HOT 5
- Poor Result when avoiding a polygonal curve HOT 6
- adjustText 1.1 doesn't work properly anymore HOT 6
- Arrows disappear when using cartopy transformation HOT 11
- query_pairs unexpected argument HOT 3
- Numpy 2.0 related issue - use of 'np.Inf`' HOT 3
- update to work with numpy 2.0 HOT 1
- Prevent text overlapping scaled scatter points HOT 3
- avoid crossing of the connector lines HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adjusttext.