Skip to content

Commit 1a8a2b5

Browse files
committed
Update renderer.py and mpltools.py for change.
1 parent de3d76d commit 1a8a2b5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

plotly/matplotlylib/mpltools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,17 @@ def prep_ticks(ax, index, ax_type, props):
422422
if ax_type == 'x' and 'DateFormatter' in formatter:
423423
axis_dict['type'] = 'date'
424424
try:
425-
axis_dict['tick0'] = mpl_dates_to_datestrings(axis_dict['tick0'])
425+
axis_dict['tick0'] = mpl_dates_to_datestrings(
426+
axis_dict['tick0'], formatter
427+
)
426428
except KeyError:
427429
pass
428430
finally:
429431
axis_dict.pop('dtick', None)
430432
axis_dict.pop('autotick', None)
431-
axis_dict['range'] = mpl_dates_to_datestrings(props['xlim'])
433+
axis_dict['range'] = mpl_dates_to_datestrings(
434+
props['xlim'], formatter
435+
)
432436

433437
if formatter == 'LogFormatterMathtext':
434438
axis_dict['exponentformat'] = 'e'

plotly/matplotlylib/renderer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ def draw_bar(self, coll):
258258
[bar['x1'] for bar in trace])
259259
if self.x_is_mpl_date:
260260
x = [bar['x0'] for bar in trace]
261-
x = mpltools.mpl_dates_to_datestrings(x)
261+
formatter = (self.current_mpl_ax.get_xaxis()
262+
.get_major_formatter().__class__.__name__)
263+
x = mpltools.mpl_dates_to_datestrings(x, formatter)
262264
else:
263265
self.msg += " Attempting to draw a horizontal bar chart\n"
264266
old_rights = [bar_props['x1'] for bar_props in trace]
@@ -367,8 +369,10 @@ def draw_marked_line(self, **props):
367369
line=line,
368370
marker=marker)
369371
if self.x_is_mpl_date:
372+
formatter = (self.current_mpl_ax.get_xaxis()
373+
.get_major_formatter().__class__.__name__)
370374
marked_line['x'] = mpltools.mpl_dates_to_datestrings(
371-
marked_line['x']
375+
marked_line['x'], formatter
372376
)
373377
self.plotly_fig['data'] += marked_line,
374378
self.msg += " Heck yeah, I drew that line\n"

0 commit comments

Comments
 (0)