Skip to content

x/y tick label color is not honored #65

Description

@romintomasetti

Describe the bug

The x/y tick label color is not honored.

To Reproduce

I ran the following with Python 3.12.3, and matplot2tikz 0.5.4:

import matplotlib.pyplot as plt
import matplot2tikz

COLOR='tab:red'

fig, ax = plt.subplots()

ax.plot([0, 1, 2, 3], [4, 5, 6, 7], color=COLOR)

ax.set_ylabel(f'This should be colored in {COLOR}!', color=COLOR)
ax.tick_params(axis='y', labelcolor=COLOR)
ax.tick_params(axis='x', labelcolor=COLOR)

ax.set_xlabel(f'Version {matplot2tikz.__version__}', color=COLOR)

fig.savefig('test.svg', bbox_inches=0, transparent=False)

matplot2tikz.save(figure=fig, filepath='test.tex')

The expected output is as follows (note the red colored x/y tick labels):
Image
but the TikZ output clearly does not honor the x/y tick label color:

% This file was created with matplot2tikz v0.5.4.
\begin{tikzpicture}

\definecolor{crimson2143940}{RGB}{214,39,40}
\definecolor{darkgray176}{RGB}{176,176,176}

\begin{axis}[
tick align=outside,
tick pos=left,
x grid style={darkgray176},
xlabel=\textcolor{crimson2143940}{Version 0.5.4},
xmin=-0.15, xmax=3.15,
xtick style={color=black},
y grid style={darkgray176},
ylabel=\textcolor{crimson2143940}{This should be colored in tab:red!},
ymin=3.85, ymax=7.15,
ytick style={color=black}
]
\addplot [semithick, crimson2143940]
table {%
0 4
1 5
2 6
3 7
};
\end{axis}

\end{tikzpicture}

Expected behavior

I think the x/y tick coloring should be done through something like:

yticklabel style={color=...}

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