Tikzplotlib not outputting Matplotlib's PyPlot colour bars

71 Views Asked by At

I'm trying to output contour plots made with PyPlot to Tikz using Tikzplotlib, but the color bars aren't appearing in the outputted TeX code.
The contour plots themselves aren't appearing either because the draw=none command is added in each in \addplot command. But, I can change that manually.
The color bars, however, don't even seem to be registered by Tikzplotlib as there is no sign of them in the TeX code.

My Python code is as follows and generates the

desired result:

import matplotlib.pyplot as plt
import matplotlib.transforms as transforms
import tikzplotlib
import numpy as np
import math

x_min=0
x_max=1
y_min=0
y_max=1
n_x=7
n_y=7
x=np.linspace(x_min,x_max,n_x)
y=np.linspace(y_min,y_max,n_y)
X, Y = np.meshgrid(x, y)

fig, ax = plt.subplots(1,1, figsize=(12,6))

Z=X+Y
mycmap1 = plt.get_cmap()
ax.set_aspect('equal')
cf=ax.contour(X,Y,Z,cmap=mycmap1)
plt.colorbar(cf, ax=ax)
tikzplotlib.save("solution.tex",standalone=True)
plt.show()

The Tikzplotlib output is only without a color bar.

I'm specifically looking to keep the style and design of the Python color bar and would prefer not having to manually code it in TeX.

I've tried moving the tikzplotlib.save() command and adding a label to the color bar but to no avail.

Thanks for your help

0

There are 0 best solutions below