Как увидеть каждую дату в каждой точке, используя mpldatacursor points_labels? И функция pprint_val устарела в Matplotlib 3.1 - PullRequest
0 голосов
/ 24 апреля 2020

Я зову на помощь, потому что в моем скрипте python что-то не так ... Я хочу отображать даты при нажатии на мои точки, но в результате весь список дат печатается в каждой точке. .

#lon_valid and lat_valid are both a list of coordinates
#times_to_dates is a list of datetimes objects
#both these lists are long (about 300k objects)
strin=[str(w) for w in times_to_dates]

if len(lon_valid)==len(lat_valid):
        fig, ax=plt.subplots()
        fig.suptitle("Latitude vs longitude, on mooring "+str(my_file.platform_name)+" ("+str(my_file.platform_code)+")")
        ax.set_xlabel("longitude (°)")
        ax.set_ylabel("latitude (°)")
        plt.xticks(fontsize=7)
        ax.scatter(lon_valid,lat_valid,)
        datacursor(axes=ax, point_labels=strin)
        plt.show()
else: print("Error: Number of datas between VHM0 and TIME different")

Вот скриншот, чтобы прояснить ситуацию: screenshot_too_many_dates

Не могли бы вы объяснить, в чем проблема? Кажется, он связан с переменной point_labels, но знает, как ее решить. Я попробовал только с несколькими точками и небольшим списком, здесь все в порядке ...

labels = [str(datetime(2004,12,4)), str(datetime(2005,5,4)), 'c', 'd', 'e', 'f']
x = [0, 0.05, 1, 2, 3, 4]
# All points on this figure will point labels.
fig, ax = plt.subplots()
ax.plot(x, x, 'ro')
ax.margins(0.1)
datacursor(axes=ax, point_labels=labels)
plt.show()

Наконец, я также хотел бы знать, является ли это сообщение большой проблемой или нет ... можно будет использовать mpldatacursor в будущем так же, как и раньше, или будет необходимо изменить сценарии?

/lib/python3.7/site-packages/mpldatacursor/datacursor.py:413: MatplotlibDeprecationWarning:
The pprint_val function was deprecated in Matplotlib 3.1 and will be removed in 3.3.

Большое спасибо за вашу помощь! :)

...