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

Cannot use 'figurewidth' or 'figureheight' when saving a plot on Ubuntu 18/Python3.6 & 3.7

addola opened this issue · comments

When saving a figure, I cannot use 'figurewidth' or 'figureheight' on my Ubuntu machine. The same code works on my macOS machine, but not on my Ubuntu. There is absolutely no mention of 'figureheight' or 'figurewidth' in the documentation pages.

import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
plt.plot (x, y)
import tikzplotlib
tikzplotlib.save ('output.tex', figurewidth='15cm', figureheight='5cm')

This results in an error:
TypeError: get_tikz_code() got an unexpected keyword argument 'figurewidth'

You may be looking for axis_width.

Uha! That actually worked! Thank you so much! I wasn't sure why figurewidth and figureheight worked on my macOS, but not Ubuntu. Has it been changed to axis_width and axis_height in recent versions? Because I have seen many examples suggesting the use of figurewidth & figureheight, and I was going crazy looking for that in the documentation.

It has changed at some point in the past, certainly not recently. When in doubt, just look at the code.

Sorry for responding to a closed issue, but would it be a good idea to print a warning message pointing people to the new parameters if the old parameters are used? It would save people having to look at the code.