Skip to content

3.3.0: possible regression/bug with DateFormatter? #18010

Closed

Description

@sandrotosi

Hello,
i have this code that worked fine until mpl 3.3.0; now if you run it, it generate this image - notice the X axes tick labels, 3989? that's supposed to be 2020 :) (for comparison you can look at last month image )

Is there anything wrong with that code i was using or is there a bug/regression in mpl?

thanks!

Activity

  1. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    https://matplotlib.org/3.3.0/users/whats_new.html#dates-use-a-modern-epoch

    But I don't understand why your dates, which seem to be just datetime objects, are not just working.

  2. added this to the v3.3.1 milestone on Jul 22, 2020
  3. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    I cannot reproduce this on master or v.3.3.0.

    I get:

    EB3

    Even if I change plt.rcParams['date.epoch'] = '1970-01-01T00:00:00' or plt.rcParams['date.epoch'] = '0000-12-31T00:00:00' I get the same image. So this is a bit of a mystery as to why its not working for you.

  4. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    If you do

    import matplotlib.dates as mdates
    import datetime
    
    print(mdates.get_epoch())
    print(mdates.date2num(datetime.datetime(2020, 1, 1)))

    and report the results, that would be useful. For me I get

    1970-01-01T00:00:00
    18262.0
    
  5. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor

    yep, same:

    In [62]: import matplotlib.dates as mdates 
        ...: import datetime 
        ...:  
        ...: print(mdates.get_epoch()) 
        ...: print(mdates.date2num(datetime.datetime(2020, 1, 1)))                                                                                                                                                                                                                  
    1970-01-01T00:00:00
    18262.0
    
    In [63]: matplotlib.__version__                                                                                                                                                                                                                                                 
    Out[63]: '3.3.0'
    
  6. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor

    could be some outdated rcparams?

    In [64]: matplotlib.rcParams                                                                                                                                                                                                                                                    
    Out[64]: 
    RcParams({'_internal.classic_mode': False,
              'agg.path.chunksize': 0,
              'animation.avconv_args': [],
              'animation.avconv_path': 'avconv',
              'animation.bitrate': -1,
              'animation.codec': 'h264',
              'animation.convert_args': [],
              'animation.convert_path': 'convert',
              'animation.embed_limit': 20.0,
              'animation.ffmpeg_args': [],
              'animation.ffmpeg_path': 'ffmpeg',
              'animation.frame_format': 'png',
              'animation.html': 'none',
              'animation.html_args': [],
              'animation.writer': 'ffmpeg',
              'axes.autolimit_mode': 'data',
              'axes.axisbelow': 'line',
              'axes.edgecolor': 'black',
              'axes.facecolor': 'white',
              'axes.formatter.limits': [-5, 6],
              'axes.formatter.min_exponent': 0,
              'axes.formatter.offset_threshold': 4,
              'axes.formatter.use_locale': False,
              'axes.formatter.use_mathtext': False,
              'axes.formatter.useoffset': True,
              'axes.grid': False,
              'axes.grid.axis': 'both',
              'axes.grid.which': 'major',
              'axes.labelcolor': 'black',
              'axes.labelpad': 4.0,
              'axes.labelsize': 'medium',
              'axes.labelweight': 'normal',
              'axes.linewidth': 0.8,
              'axes.prop_cycle': cycler('color', ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']),
              'axes.spines.bottom': True,
              'axes.spines.left': True,
              'axes.spines.right': True,
              'axes.spines.top': True,
              'axes.titlecolor': 'auto',
              'axes.titlelocation': 'center',
              'axes.titlepad': 6.0,
              'axes.titlesize': 'large',
              'axes.titleweight': 'normal',
              'axes.titley': None,
              'axes.unicode_minus': True,
              'axes.xmargin': 0.05,
              'axes.ymargin': 0.05,
              'axes3d.grid': True,
              'backend': 'TkAgg',
              'backend_fallback': True,
              'boxplot.bootstrap': None,
              'boxplot.boxprops.color': 'black',
              'boxplot.boxprops.linestyle': '-',
              'boxplot.boxprops.linewidth': 1.0,
              'boxplot.capprops.color': 'black',
              'boxplot.capprops.linestyle': '-',
              'boxplot.capprops.linewidth': 1.0,
              'boxplot.flierprops.color': 'black',
              'boxplot.flierprops.linestyle': 'none',
              'boxplot.flierprops.linewidth': 1.0,
              'boxplot.flierprops.marker': 'o',
              'boxplot.flierprops.markeredgecolor': 'black',
              'boxplot.flierprops.markeredgewidth': 1.0,
              'boxplot.flierprops.markerfacecolor': 'none',
              'boxplot.flierprops.markersize': 6.0,
              'boxplot.meanline': False,
              'boxplot.meanprops.color': 'C2',
              'boxplot.meanprops.linestyle': '--',
              'boxplot.meanprops.linewidth': 1.0,
              'boxplot.meanprops.marker': '^',
              'boxplot.meanprops.markeredgecolor': 'C2',
              'boxplot.meanprops.markerfacecolor': 'C2',
              'boxplot.meanprops.markersize': 6.0,
              'boxplot.medianprops.color': 'C1',
              'boxplot.medianprops.linestyle': '-',
              'boxplot.medianprops.linewidth': 1.0,
              'boxplot.notch': False,
              'boxplot.patchartist': False,
              'boxplot.showbox': True,
              'boxplot.showcaps': True,
              'boxplot.showfliers': True,
              'boxplot.showmeans': False,
              'boxplot.vertical': True,
              'boxplot.whiskerprops.color': 'black',
              'boxplot.whiskerprops.linestyle': '-',
              'boxplot.whiskerprops.linewidth': 1.0,
              'boxplot.whiskers': 1.5,
              'contour.corner_mask': True,
              'contour.linewidth': None,
              'contour.negative_linestyle': 'dashed',
              'date.autoformatter.day': '%Y-%m-%d',
              'date.autoformatter.hour': '%m-%d %H',
              'date.autoformatter.microsecond': '%M:%S.%f',
              'date.autoformatter.minute': '%d %H:%M',
              'date.autoformatter.month': '%Y-%m',
              'date.autoformatter.second': '%H:%M:%S',
              'date.autoformatter.year': '%Y',
              'date.epoch': '1970-01-01T00:00:00',
              'docstring.hardcopy': False,
              'errorbar.capsize': 0.0,
              'figure.autolayout': False,
              'figure.constrained_layout.h_pad': 0.04167,
              'figure.constrained_layout.hspace': 0.02,
              'figure.constrained_layout.use': False,
              'figure.constrained_layout.w_pad': 0.04167,
              'figure.constrained_layout.wspace': 0.02,
              'figure.dpi': 100.0,
              'figure.edgecolor': 'white',
              'figure.facecolor': 'white',
              'figure.figsize': [6.4, 4.8],
              'figure.frameon': True,
              'figure.max_open_warning': 20,
              'figure.raise_window': True,
              'figure.subplot.bottom': 0.11,
              'figure.subplot.hspace': 0.2,
              'figure.subplot.left': 0.125,
              'figure.subplot.right': 0.9,
              'figure.subplot.top': 0.88,
              'figure.subplot.wspace': 0.2,
              'figure.titlesize': 'large',
              'figure.titleweight': 'normal',
              'font.cursive': ['Apple Chancery',
                               'Textile',
                               'Zapf Chancery',
                               'Sand',
                               'Script MT',
                               'Felipa',
                               'cursive'],
              'font.family': ['sans-serif'],
              'font.fantasy': ['Comic Neue',
                               'Comic Sans MS',
                               'Chicago',
                               'Charcoal',
                               'ImpactWestern',
                               'Humor Sans',
                               'xkcd',
                               'fantasy'],
              'font.monospace': ['DejaVu Sans Mono',
                                 'Bitstream Vera Sans Mono',
                                 'Computer Modern Typewriter',
                                 'Andale Mono',
                                 'Nimbus Mono L',
                                 'Courier New',
                                 'Courier',
                                 'Fixed',
                                 'Terminal',
                                 'monospace'],
              'font.sans-serif': ['DejaVu Sans',
                                  'Bitstream Vera Sans',
                                  'Computer Modern Sans Serif',
                                  'Lucida Grande',
                                  'Verdana',
                                  'Geneva',
                                  'Lucid',
                                  'Arial',
                                  'Helvetica',
                                  'Avant Garde',
                                  'sans-serif'],
              'font.serif': ['DejaVu Serif',
                             'Bitstream Vera Serif',
                             'Computer Modern Roman',
                             'New Century Schoolbook',
                             'Century Schoolbook L',
                             'Utopia',
                             'ITC Bookman',
                             'Bookman',
                             'Nimbus Roman No9 L',
                             'Times New Roman',
                             'Times',
                             'Palatino',
                             'Charter',
                             'serif'],
              'font.size': 10.0,
              'font.stretch': 'normal',
              'font.style': 'normal',
              'font.variant': 'normal',
              'font.weight': 'normal',
              'grid.alpha': 1.0,
              'grid.color': '#b0b0b0',
              'grid.linestyle': '-',
              'grid.linewidth': 0.8,
              'hatch.color': 'black',
              'hatch.linewidth': 1.0,
              'hist.bins': 10,
              'image.aspect': 'equal',
              'image.cmap': 'viridis',
              'image.composite_image': True,
              'image.interpolation': 'antialiased',
              'image.lut': 256,
              'image.origin': 'upper',
              'image.resample': True,
              'interactive': False,
              'keymap.all_axes': ['a'],
              'keymap.back': ['left', 'c', 'backspace', 'MouseButton.BACK'],
              'keymap.copy': ['ctrl+c', 'cmd+c'],
              'keymap.forward': ['right', 'v', 'MouseButton.FORWARD'],
              'keymap.fullscreen': ['f', 'ctrl+f'],
              'keymap.grid': ['g'],
              'keymap.grid_minor': ['G'],
              'keymap.help': ['f1'],
              'keymap.home': ['h', 'r', 'home'],
              'keymap.pan': ['p'],
              'keymap.quit': ['ctrl+w', 'cmd+w', 'q'],
              'keymap.quit_all': [],
              'keymap.save': ['s', 'ctrl+s'],
              'keymap.xscale': ['k', 'L'],
              'keymap.yscale': ['l'],
              'keymap.zoom': ['o'],
              'legend.borderaxespad': 0.5,
              'legend.borderpad': 0.4,
              'legend.columnspacing': 2.0,
              'legend.edgecolor': '0.8',
              'legend.facecolor': 'inherit',
              'legend.fancybox': True,
              'legend.fontsize': 'medium',
              'legend.framealpha': 0.8,
              'legend.frameon': True,
              'legend.handleheight': 0.7,
              'legend.handlelength': 2.0,
              'legend.handletextpad': 0.8,
              'legend.labelspacing': 0.5,
              'legend.loc': 'best',
              'legend.markerscale': 1.0,
              'legend.numpoints': 1,
              'legend.scatterpoints': 1,
              'legend.shadow': False,
              'legend.title_fontsize': None,
              'lines.antialiased': True,
              'lines.color': 'C0',
              'lines.dash_capstyle': 'butt',
              'lines.dash_joinstyle': 'round',
              'lines.dashdot_pattern': [6.4, 1.6, 1.0, 1.6],
              'lines.dashed_pattern': [3.7, 1.6],
              'lines.dotted_pattern': [1.0, 1.65],
              'lines.linestyle': '-',
              'lines.linewidth': 1.5,
              'lines.marker': 'None',
              'lines.markeredgecolor': 'auto',
              'lines.markeredgewidth': 1.0,
              'lines.markerfacecolor': 'auto',
              'lines.markersize': 6.0,
              'lines.scale_dashes': True,
              'lines.solid_capstyle': 'projecting',
              'lines.solid_joinstyle': 'round',
              'markers.fillstyle': 'full',
              'mathtext.bf': 'sans:bold',
              'mathtext.cal': 'cursive',
              'mathtext.default': 'it',
              'mathtext.fallback': 'cm',
              'mathtext.fallback_to_cm': None,
              'mathtext.fontset': 'dejavusans',
              'mathtext.it': 'sans:italic',
              'mathtext.rm': 'sans',
              'mathtext.sf': 'sans',
              'mathtext.tt': 'monospace',
              'mpl_toolkits.legacy_colorbar': True,
              'patch.antialiased': True,
              'patch.edgecolor': 'black',
              'patch.facecolor': 'C0',
              'patch.force_edgecolor': False,
              'patch.linewidth': 1.0,
              'path.effects': [],
              'path.simplify': True,
              'path.simplify_threshold': 0.111111111111,
              'path.sketch': None,
              'path.snap': True,
              'pcolor.shading': 'flat',
              'pdf.compression': 6,
              'pdf.fonttype': 3,
              'pdf.inheritcolor': False,
              'pdf.use14corefonts': False,
              'pgf.preamble': '',
              'pgf.rcfonts': True,
              'pgf.texsystem': 'xelatex',
              'polaraxes.grid': True,
              'ps.distiller.res': 6000,
              'ps.fonttype': 3,
              'ps.papersize': 'letter',
              'ps.useafm': False,
              'ps.usedistiller': None,
              'savefig.bbox': None,
              'savefig.directory': '~',
              'savefig.dpi': 'figure',
              'savefig.edgecolor': 'auto',
              'savefig.facecolor': 'auto',
              'savefig.format': 'png',
              'savefig.jpeg_quality': 95,
              'savefig.orientation': 'portrait',
              'savefig.pad_inches': 0.1,
              'savefig.transparent': False,
              'scatter.edgecolors': 'face',
              'scatter.marker': 'o',
              'svg.fonttype': 'path',
              'svg.hashsalt': None,
              'svg.image_inline': True,
              'text.antialiased': True,
              'text.color': 'black',
              'text.hinting': 'force_autohint',
              'text.hinting_factor': 8,
              'text.kerning_factor': 0,
              'text.latex.preamble': '',
              'text.latex.preview': False,
              'text.usetex': False,
              'timezone': 'UTC',
              'tk.window_focus': False,
              'toolbar': 'toolbar2',
              'webagg.address': '127.0.0.1',
              'webagg.open_in_browser': True,
              'webagg.port': 8988,
              'webagg.port_retries': 50,
              'xaxis.labellocation': 'center',
              'xtick.alignment': 'center',
              'xtick.bottom': True,
              'xtick.color': 'black',
              'xtick.direction': 'out',
              'xtick.labelbottom': True,
              'xtick.labelsize': 'medium',
              'xtick.labeltop': False,
              'xtick.major.bottom': True,
              'xtick.major.pad': 3.5,
              'xtick.major.size': 3.5,
              'xtick.major.top': True,
              'xtick.major.width': 0.8,
              'xtick.minor.bottom': True,
              'xtick.minor.pad': 3.4,
              'xtick.minor.size': 2.0,
              'xtick.minor.top': True,
              'xtick.minor.visible': False,
              'xtick.minor.width': 0.6,
              'xtick.top': False,
              'yaxis.labellocation': 'center',
              'ytick.alignment': 'center_baseline',
              'ytick.color': 'black',
              'ytick.direction': 'out',
              'ytick.labelleft': True,
              'ytick.labelright': False,
              'ytick.labelsize': 'medium',
              'ytick.left': True,
              'ytick.major.left': True,
              'ytick.major.pad': 3.5,
              'ytick.major.right': True,
              'ytick.major.size': 3.5,
              'ytick.major.width': 0.8,
              'ytick.minor.left': True,
              'ytick.minor.pad': 3.4,
              'ytick.minor.right': True,
              'ytick.minor.size': 2.0,
              'ytick.minor.visible': False,
              'ytick.minor.width': 0.6,
              'ytick.right': False})
    
  7. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    The relevant new rcParam is date.epoch and its correct.

    Is it something funny in your env? What happens if you simplify this to:

    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    import datetime
    import numpy as np
    
    print(mdates.get_epoch())
    print(mdates.date2num(datetime.datetime(2020, 1, 1)))
    
    dates = {datetime.datetime(2016, 2, 1, 0, 0): datetime.datetime(2015, 10, 1, 0, 0), datetime.datetime(2020, 6, 1, 0, 0): datetime.datetime(2017, 11, 8, 0, 0), datetime.datetime(2017, 8, 1, 0, 0): datetime.datetime(2017, 8, 1, 0, 0), datetime.datetime(2018, 4, 1, 0, 0): datetime.datetime(2018, 4, 1, 0, 0), datetime.datetime(2020, 8, 1, 0, 0): datetime.datetime(2019, 4, 1, 0, 0), datetime.datetime(2019, 11, 1, 0, 0): datetime.datetime(2019, 11, 1, 0, 0), datetime.datetime(2019, 9, 1, 0, 0): datetime.datetime(2016, 7, 1, 0, 0), datetime.datetime(2019, 5, 1, 0, 0): datetime.datetime(2019, 5, 1, 0, 0), datetime.datetime(2018, 6, 1, 0, 0): datetime.datetime(2018, 6, 1, 0, 0), datetime.datetime(2020, 1, 1, 0, 0): datetime.datetime(2020, 1, 1, 0, 0), datetime.datetime(2018, 2, 1, 0, 0): datetime.datetime(2018, 2, 1, 0, 0), datetime.datetime(2017, 7, 1, 0, 0): datetime.datetime(2017, 6, 8, 0, 0), datetime.datetime(2017, 12, 1, 0, 0): datetime.datetime(2017, 12, 1, 0, 0), datetime.datetime(2017, 9, 1, 0, 0): datetime.datetime(2017, 9, 1, 0, 0), datetime.datetime(2019, 1, 1, 0, 0): datetime.datetime(2019, 1, 1, 0, 0), datetime.datetime(2019, 3, 1, 0, 0): datetime.datetime(2019, 3, 1, 0, 0), datetime.datetime(2016, 9, 1, 0, 0): datetime.datetime(2016, 5, 1, 0, 0), datetime.datetime(2018, 10, 1, 0, 0): datetime.datetime(2018, 10, 1, 0, 0), datetime.datetime(2016, 12, 1, 0, 0): datetime.datetime(2016, 7, 1, 0, 0), datetime.datetime(2016, 4, 1, 0, 0): datetime.datetime(2016, 2, 15, 0, 0), datetime.datetime(2018, 8, 1, 0, 0): datetime.datetime(2018, 8, 1, 0, 0), datetime.datetime(2015, 11, 1, 0, 0): datetime.datetime(2015, 8, 15, 0, 0), datetime.datetime(2019, 7, 1, 0, 0): datetime.datetime(2019, 7, 1, 0, 0), datetime.datetime(2018, 5, 1, 0, 0): datetime.datetime(2018, 5, 1, 0, 0), datetime.datetime(2017, 10, 1, 0, 0): datetime.datetime(2017, 10, 1, 0, 0), datetime.datetime(2015, 12, 1, 0, 0): datetime.datetime(2015, 9, 1, 0, 0), datetime.datetime(2020, 2, 1, 0, 0): datetime.datetime(2020, 2, 1, 0, 0), datetime.datetime(2016, 7, 1, 0, 0): datetime.datetime(2016, 3, 1, 0, 0), datetime.datetime(2016, 3, 1, 0, 0): datetime.datetime(2016, 1, 1, 0, 0), datetime.datetime(2019, 10, 1, 0, 0): datetime.datetime(2019, 10, 1, 0, 0), datetime.datetime(2020, 5, 1, 0, 0): datetime.datetime(2017, 1, 1, 0, 0), datetime.datetime(2019, 2, 1, 0, 0): datetime.datetime(2019, 2, 1, 0, 0), datetime.datetime(2019, 4, 1, 0, 0): datetime.datetime(2019, 4, 1, 0, 0), datetime.datetime(2018, 11, 1, 0, 0): datetime.datetime(2018, 11, 1, 0, 0), datetime.datetime(2017, 5, 1, 0, 0): datetime.datetime(2017, 3, 15, 0, 0), datetime.datetime(2019, 6, 1, 0, 0): datetime.datetime(2019, 6, 1, 0, 0), datetime.datetime(2017, 1, 1, 0, 0): datetime.datetime(2016, 8, 1, 0, 0), datetime.datetime(2018, 3, 1, 0, 0): datetime.datetime(2018, 3, 1, 0, 0), datetime.datetime(2020, 4, 1, 0, 0): datetime.datetime(2017, 1, 1, 0, 0), datetime.datetime(2018, 1, 1, 0, 0): datetime.datetime(2018, 1, 1, 0, 0), datetime.datetime(2017, 11, 1, 0, 0): datetime.datetime(2017, 11, 1, 0, 0), datetime.datetime(2020, 3, 1, 0, 0): datetime.datetime(2017, 1, 1, 0, 0), datetime.datetime(2017, 2, 1, 0, 0): datetime.datetime(2016, 10, 1, 0, 0), datetime.datetime(2016, 6, 1, 0, 0): datetime.datetime(2016, 2, 15, 0, 0), datetime.datetime(2016, 10, 1, 0, 0): datetime.datetime(2016, 6, 1, 0, 0), datetime.datetime(2020, 7, 1, 0, 0): datetime.datetime(2018, 4, 15, 0, 0), datetime.datetime(2017, 6, 1, 0, 0): datetime.datetime(2017, 4, 15, 0, 0), datetime.datetime(2018, 12, 1, 0, 0): datetime.datetime(2018, 12, 1, 0, 0), datetime.datetime(2018, 7, 1, 0, 0): datetime.datetime(2018, 7, 1, 0, 0), datetime.datetime(2016, 11, 1, 0, 0): datetime.datetime(2016, 7, 1, 0, 0), datetime.datetime(2016, 1, 1, 0, 0): datetime.datetime(2015, 10, 1, 0, 0), datetime.datetime(2016, 8, 1, 0, 0): datetime.datetime(2016, 3, 15, 0, 0), datetime.datetime(2019, 12, 1, 0, 0): datetime.datetime(2019, 12, 1, 0, 0), datetime.datetime(2016, 5, 1, 0, 0): datetime.datetime(2016, 2, 15, 0, 0), datetime.datetime(2015, 10, 1, 0, 0): datetime.datetime(2015, 8, 15, 0, 0), datetime.datetime(2017, 4, 1, 0, 0): datetime.datetime(2017, 2, 15, 0, 0), datetime.datetime(2017, 3, 1, 0, 0): datetime.datetime(2016, 12, 1, 0, 0), datetime.datetime(2019, 8, 1, 0, 0): datetime.datetime(2016, 7, 1, 0, 0), datetime.datetime(2018, 9, 1, 0, 0): datetime.datetime(2016, 11, 1, 0, 0)}
    
    plt.plot(sorted(dates.keys()), np.arange(len(dates)))
    plt.show()

    from your ipython shell does it still give the strange dates? EDIT: they're not strange, they are just 1970 years too far in the future. ie the datenum is coming out as one that has the old epoch, but then getting converted back using the new one.

  8. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    Also can't hurt to make sure this roundtrips:

    print(mdates.num2date(18262.0))
    
  9. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor

    i tried your code and i get the weird dates
    issue18010

  10. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor
    In [66]: print(mdates.num2date(18262.0))                                                                                                                                                                                                                                        
    2020-01-01 00:00:00+00:00
    
    
  11. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor

    (if you prefer a different way to debug this, like maybe on discord or smth, just let me know :) )

  12. jklymak commented on Jul 22, 2020

    @jklymak
    Member
    loc = mdates.AutoDateLocator()
    formatter = mdates.AutoDateFormatter(loc)
    print(formatter(18262.0))

    Gives me 2020...

  13. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    BTW, not sure if discord would help, and this is fine for tracking the issue. OTOH, I'm not sure what else I can do. It'd be good if you could reproduce on a fresh env. If I do conda create -n boo matplotlib numpy and conda activate boo I get the same results. So I'm pretty mystified.

  14. 2 remaining items

  15. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor

    weirder and weirder: if i restart ipython, i get the right dates too! but i run the original script from the command-line, still 3989 ....

  16. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    That is strange - seems like a crossed-up install, but not sure I understand why. I guess you could put the print statements above into a script and run from the command line.

  17. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor
    $ cat ~/tmp/issue18010_1.py
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    import datetime
    import numpy as np
    
    loc = mdates.AutoDateLocator()
    formatter = mdates.AutoDateFormatter(loc)
    print(formatter(18262.0))
    
    print(mdates.num2date(18262.0))
    
    $ python3 ~/tmp/issue18010_1.py
    2020
    2020-01-01 00:00:00+00:00
    
  18. sandrotosi commented on Jul 22, 2020

    @sandrotosi
    ContributorAuthor

    ok, it looks like i may have had to pay more attention to the message on the console:

    /usr/lib/python3/dist-packages/pandas/plotting/_matplotlib/converter.py:103: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters.
    
    To register the converters:
            >>> from pandas.plotting import register_matplotlib_converters
            >>> register_matplotlib_converters()
      warnings.warn(msg, FutureWarning)
    /usr/lib/python3/dist-packages/pandas/plotting/_matplotlib/converter.py:245: MatplotlibDeprecationWarning: 
    The epoch2num function was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
      base = dates.epoch2num(dt.asi8 / 1.0e9)
    

    that's produced when executing the script on console: is this our smoking gun?

  19. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    Yes; Epoch2num was not updated to the new epoch. So this will be closed by a PR from yesterday. But I still don't 100% understand because you are explicitly using matplotlib's formatter.

  20. jklymak commented on Jul 22, 2020

    @jklymak
    Member

    @sandrotosi so was one of your pandas pre 1.0.0?

    I think all this speaks to getting #17983 in a release as soon as possible to address this conflict, at least for folks using older pandas. See also pandas-dev/pandas#35350, pandas-dev/pandas#34850, and pandas-dev/pandas#35361

  21. sandrotosi commented on Jul 23, 2020

    @sandrotosi
    ContributorAuthor

    @sandrotosi so was one of your pandas pre 1.0.0?

    yes, on my system i have pandas/0.25.3 while there is no pandas installed in the container

    I think all this speaks to getting #17983 in a release as soon as possible to address this conflict, at least for folks using older pandas. See also pandas-dev/pandas#35350, pandas-dev/pandas#34850, and pandas-dev/pandas#35361

    lemme apply that patch (hoping it applies cleanly on top of 3.3.0) to the debian package and re-try; will update as soon as the build process finishes so... not very soon :)

  22. sandrotosi commented on Jul 23, 2020

    @sandrotosi
    ContributorAuthor

    yep that was it: with that PR applied on top of 3.3.0, the script now works fine. i'm gonna upload the fix to Debian, but I agree a .1 with that patch released officially would be ideal -- thanks for debugging this with me!

  23. cottrell commented on Jul 24, 2020

    @cottrell

    Can someone unpack this thread? What is the final outcome as it stands?

  24. cottrell commented on Jul 24, 2020

    @cottrell

    tldr; for those landing here. Using matplotlib master fixes this.

  25. QuLogic commented on Jul 24, 2020

    @QuLogic
    Member

    Closing, as this will be fixed in 3.3.1.

  26. jklymak commented on Jul 24, 2020

    @jklymak
    Member

    Just for posterity sake, the workaround is to manually specify the old pre-3.3.0 epoch in your script.

    plt.rcParams['date.epoch'] = '0000-12-31T00:00'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions