def mpl_dates_to_datestrings(dates, mpl_formatter):
    _dates = dates

    # this is a pandas datetime formatter, times show up in floating point days
    # since the epoch (1970-01-01T00:00:00+00:00)
    if mpl_formatter == "TimeSeries_DateFormatter":
        try:
            dates = matplotlib.dates.epoch2num(
                [date*24*60*60 for date in dates]
            )
            dates = matplotlib.dates.num2date(dates, tz=pytz.utc)
        except:
            return _dates

    # the rest of mpl dates are in floating point days since
    # (0001-01-01T00:00:00+00:00) + 1. I.e., (0001-01-01T00:00:00+00:00) == 1.0
    # according to mpl --> try num2date(1)
    else:
        try:
            dates = matplotlib.dates.num2date(dates, tz=pytz.utc)
        except:
            return _dates

    time_stings = [' '.join(date.isoformat().split('+')[0].split('T'))
                   for date in dates]
    return time_stings
Convert matplotlib dates to iso-formatted-like time strings.
dataset/ETHPy150Open plotly/plotly.py/plotly/matplotlylib/mpltools.py/mpl_dates_to_datestrings