nschloe/tikzplotlib

Colorbar not exporting correctly

finnBsch opened this issue · 1 comments

When I try to use tikzplotlib to gert a plot with a colorbar similar to all the tests given in https://github.com/nschloe/tikzplotlib/blob/main/tests/test_colorbars.py it either returns a .tex with no colorbar in it or something that uses an image of a the colorbar that's slightly offset and not correctly scaled. Is there a way to make it use tikz colorbar?

Thanks!

Can you give a minimal example where that happens?

I remember having a similar problem where tikzplotlib produced a tikzpicture with two axes and the second one being an image of the colorbar. If I deleted the second axes from the tikzpicture everything looked fine and there was a default colorbar. However I cannot reproduce this behaviour right now. I tried the following code:

import matplotlib.pyplot as plt
import tikzplotlib as tpl
import numpy as np

# example of a colorbar plot
fig, ax = plt.subplots(1, 1, figsize=(4,4))
im = ax.matshow(np.random.randn(256, 256), origin='lower')
plt.colorbar(im, label="some label", orientation="vertical")
ax.set_ylabel("y")
ax.set_xlabel("x")

tpl.save(filepath=r"colorbar.tex", standalone=True, encoding='utf-8')

which produces
image