Skip to content

Figure should not be empty when exporting a colorbar #606

Description

@JasonGross
# %%
import matplotlib as mpl
import matplotlib.pyplot as plt
import tikzplotlib
# example from https://matplotlib.org/stable/users/explain/colors/colorbar_only.html#basic-continuous-colorbar
fig, ax = plt.subplots(figsize=(6, 1), layout='constrained')

cmap = mpl.cm.cool
norm = mpl.colors.Normalize(vmin=5, vmax=10)

fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap),
             cax=ax, orientation='horizontal', label='Some Units')
print(tikzplotlib.get_tikz_code(fig))

gives

% This file was created with tikzplotlib v0.10.1.
\begin{tikzpicture}

\end{tikzpicture}

But it should produce some colorbar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions