nschloe / tikzplotlib

:bar_chart: Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

trouble with log scales and clean_figure

bjuergens opened this issue · comments

clean_figure() seems to break when using log-scales.

import matplotlib.pyplot as plt
import tikzplotlib

fig, axes = plt.subplots(1)
ax = axes
ax.plot(range(1,100), range(1,100))
ax.set_yscale('log')
tikzplotlib.clean_figure()
fig.show()

output (console):

/home/name/.venv/neuro/lib/python3.8/site-packages/tikzplotlib/_cleanfigure.py:613: RuntimeWarning: divide by zero encountered in log10
  yData = np.log10(yData)
/home/name/.venv/neuro/lib/python3.8/site-packages/tikzplotlib/_cleanfigure.py:1001: RuntimeWarning: invalid value encountered in true_divide
  v = v / np.linalg.norm(v)

output (image): https://i.imgur.com/n6S42ly.png

when I comment out the line tikzplotlib.clean_figure(), don't get any console output (as expected) and the axes are scaled correctly: https://i.imgur.com/EAsrGqM.png

Perhaps @theRealSuperMario has an idea what may be causing this.

There is a fairly simple implementation: Back when the feature was requested, I only implemented log-log plots ( x AND y).

this is a semilogplot and therefore not working yet

image

Gonna fix this over the weekend, stay tuned.

Sorry for the huge delay - gonna fix it today.

PR incoming

image